How to get an array of data columns via LINQ To SQL? I'm looking for something like this :
DataColumn[] dc = DataContext.Table.Columns;
How to get an array of data columns via LINQ To SQL? I'm looking for something like this :
DataColumn[] dc = DataContext.Table.Columns;
myDataContext.Mapping.GetTable (typeof (Customer)).RowType.DataMembers
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
};