简单的1..N查询 [英] Simple 1..N Query

查看:67
本文介绍了简单的1..N查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,

我在写一个简单的查询时遇到了一些麻烦。
我有那些表:
[电影] - > 1 .. * - > [Movies_Resources ]
我试图获取没有资源(图像)的所有电影,所以我写这个:

var query =来自_objEntities.Movie.Include(" Movie_Ressources")中的项目;)
其中items.Media.Name == strMedia
选择项目;




查询=来自查询中的项目
items.IsDeleted == false&&
items.Movie_Ressources == null
选择项目;

但它不起作用:(

任何想法?

感谢您的帮助。


myCollections
http://mycollections.codeplex.com/

Hello,

I get some trouble writing a simple query.
I have those Table :
[Movies]->1..*->[Movies_Resources]

I m trying to get all the movies without resources (images) so i write this :

var query = from items in _objEntities.Movie.Include("Movie_Ressources")
                            where items.Media.Name == strMedia
                            select items;

and

query = from items in query
                                where items.IsDeleted == false &&
                                items.Movie_Ressources ==null
                                select items;

but it's not working :(

any Idea ?

Thanks for your help.


myCollections http://mycollections.codeplex.com/

推荐答案

因为资源是一个集合,它永远不会为null,你需要运行这个代码:
query = from items在查询中,其中items.IsDeleted == false&&
items.Movie_Ressources.Count == 0选择项目;

because the resource is a collection, it will never be null,
you need to run this code:
query = from items in query
                                where items.IsDeleted == false &&
                                items.Movie_Ressources.Count == 0
                                select items;


这篇关于简单的1..N查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆