转换 IEnumerable C#

Transforming an IEnumerable C#

我有一个table 'Table1' 其结构如下..

public class Table1
{
    public int Id { get; set; }
    public string SchemaName { get; set; }
    public string PropertyName { get; set; }
    public string PropertyType { get; set; }
}

使用 Entity Framework 我可以将数据作为 IEnumerable 输出。

但我需要数据为IEnumerable,其结构如下:

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; }
}

真诚感谢所有帮助。

谢谢

Table1.GroupBy(r=>r.SchemaName).Select(grp=>new myschemaobj
 {
  SchemaName = grp.Key,
  PropertyObjects = grp.Select(r=>new mypropobj
    {
      PropertyName = r.PropertyName,
      PropertyType = r.PropertyType
    })
  });