开发者

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());
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜