linq to sql query problem
I have table Profile and Table Configuration One Profile have many configuration how to select only Configuration with have at least one profile In Linq To sql
i try something like that but its not work :
public static IQueryable<Configuration> WithProfile(
this开发者_运维问答 IQueryable<Configuration> configurations)
{
return configurations.Where(
configuration => configuration.Profiles.Count() > 0 );
}
more efficient to just check if Any
rather using the count, but it sounds like something else is the cause of your problems
public static IQueryable<Configuration> WithProfile(
this IQueryable<Configuration> configurations)
{
return configurations.Where(c => c.Profiles.Any());
}
精彩评论