Hello Chuck,
It depends on where you would like to get information.
1) The simple way is to copy your dbml file into output folder. Then, you
can load that file into XMLDocument instance and retrieve each node by
XMLPath.
For example:
System.Xml.XmlDocument xd = new System.Xml.XmlDocument();
xd.Load("DataClassesName.dbml");
System.Xml.XmlNamespaceManager xnm = new
System.Xml.XmlNamespaceManager(xd.NameTable);
xnm.AddNamespace("dbml",
"
http://schemas.microsoft.com/linqtosql/dbml/2007");
string dbtype =
xd.DocumentElement.SelectSingleNode("//dbml
atabase/dbml:Table[@Name='dbo.T
able_1']/dbml:Type/dbml:Column[@Name='c1']",
xnm).Attributes["DbType"].Value;
2) Another way is to use reflection to access the ColumnAttribute class in
the System.Data.Linq.Mapping namespace.
For example:
Type linqType = typeof(Table_1);
PropertyInfo[] linqProperties = linqType.GetProperties();
foreach (PropertyInfo property in linqProperties)
{
object[] attributes =
property.GetCustomAttributes(typeof(ColumnAttribute), true);
if (attributes.Length > 0)
{
ColumnAttribute attribute = attributes[0] as
ColumnAttribute;
System.Console.WriteLine(attribute.DbType);
}
}
Brian Mains explained this method in his blog. You may refer to:
http://dotnetslackers.com/community/blogs/bmains/archive/2008/03/16/debuggin
g-linq-problems.aspx
[Debugging LINQ Problems]
Hope this helps, Please feel free to let us know if you have any more
concern. We are glad to assist you.
Have a great day,
Best regards,
Wen Yuan
Microsoft Online Community Support
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.