I have a table 'Table1' whose structure is as follows..
public class Table1
{
public int Id { get; set; }
public string SchemaName { get; set; }
public string PropertyName { get; set; }
public string PropertyType { get; set; }
}
Using Entity Framework I can get the data out as an IEnumerable.
But I need the data as IEnumerable whose structure is as follows:
public class myschemaobj
{
public string SchemaName { get; set; }
public List<mypropobj> PropertyObjects { get; set; }
}
public class mypropobj
{
public string PropertyName { get; set; }
public string PropertyType { get; set; }
}
All help is sincerely appreciated.
Thanks
Table1.GroupBy(r=>r.SchemaName).Select(grp=>new myschemaobj
{
SchemaName = grp.Key,
PropertyObjects = grp.Select(r=>new mypropobj
{
PropertyName = r.PropertyName,
PropertyType = r.PropertyType
})
});
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments