问题描述:

Following are my entity objects

public class Asset {...}

public class Picture : Asset {...}

public class Video : Asset {...}

public class Audio : Asset {...}

public class Project

{

...

public ICollection<Asset> Assets{get;set;}

...

}

How can request db.Projects.Include(x=>x.Assets.OfType<Picutre>()); using Linq, ie. to Query only Picture from List of Assets under Project.

Any Suggestions would help.. Thanks in Advance.

网友答案:

Can you try this?

var projects = from p in db.Projects
select new 
{
  Project = p,
  Pictures = p.Assets.Where(a => a is Picture)
}
相关阅读:
Top