IEnumerable<datarow> query = NgDb.UCB_Cimplicity_EReferral_GetFulfillmentsV2(companyID, clientID, programID, supplierName);
DataTable boundTable = query.CopyToDataTable<datarow>();
Or can use a customized method using reflection to convert LINQ result to datatable
public DataTable LINQResultToDataTable<t>(IEnumerable<t> Linqlist)
{
DataTable dt = new DataTable();
PropertyInfo[] columns = null;
if (Linqlist == null) return dt;
foreach (T Record in Linqlist)
{
if (columns == null)
{
columns = ((Type)Record.GetType()).GetProperties();
foreach (PropertyInfo GetProperty in columns)
{
Type colType = GetProperty.PropertyType;
if ((colType.IsGenericType) && (colType.GetGenericTypeDefinition()
== typeof(Nullable<>)))
{
colType = colType.GetGenericArguments()[0];
}
dt.Columns.Add(new DataColumn(GetProperty.Name, colType));
}
}
DataRow dr = dt.NewRow();
foreach (PropertyInfo pinfo in columns)
{
dr[pinfo.Name] = pinfo.GetValue(Record, null) == null ? DBNull.Value : pinfo.GetValue(Record, null);
}
dt.Rows.Add(dr);
}
return dt;
}