How to get an array of data columns via LINQ To SQL? I'm looking for something like this :
DataColumn[] dc = DataContext.Table.Columns;
Try:
var dataColumns =
from member in yourDataContext.Mapping.GetMetaType(typeof(YourMappedType)).DataMembers
select new DataColumn {
ColumnName = member.MappedName,
DataType = (
member.Type.IsGenericType && member.Type.GetGenericTypeDefinition() == typeof(Nullable<>)
? new NullableConverter(member.Type).UnderlyingType
: member.Type
),
AllowDBNull = member.CanBeNull
};
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With