English 中文(简体)
准则发给实体——有条件加入
原标题:LINQ to entities - left join with condition

我有一张与FK(允许作废)相配的游戏桌。 当我这样做时:

    GameVersion[] q = (from gv in db.GameVersion.Include("Game")
                       select gv).ToArray();

它在大韩民国工作,在篡夺猎物的同时,我可以看到,某些记录(如在数据带上),对野生动物的提及是无效的,因此它与左边一样。

然而,当我稍微修改问询和以游戏名称添加搜索

    GameVersion[] q = (from gv in db.GameVersion.Include("Game")
                       where gv.Game.DisplayName.Contains("a")
                       select gv).ToArray();

它突然像内部一样行事(不再选择不适用)。 我不理解这种行为。 为什么发生这种情况,我如何使问询工作? 我想选择所有狩猎者,即使有游戏=null+的人,也适用一个游戏栏的条件。

最佳回答

如果没有游戏,就不会有显示名称,这样就能够控制“a”。 如果您希望也希望<>。 选择没有游戏的游戏版本,你必须明确这样做。 为此:

GameVersion[] q = (from gv in db.GameVersion.Include("Game")
                   where gv.Game == null || gv.Game.DisplayName.Contains("a")
                   select gv).ToArray();
问题回答

暂无回答




相关问题
IEnumerable to array of parameter

Using linq? and XML is there a way to convert this IEnumerable to a string array of the value parameter? List<string> idList = new List<string>(); foreach (XElement idElement in word....

linq query for tag system - search for multiple tags

I have two tables, Tags(tagid, postid, tagname) and posts(postid, name, ...) now i want to make a query that returns me all posts that have a generic amount of tags. like: i want all posts that have ...

Linq operations against a List of Hashtables?

I m working with a set of legacy DAO code that returns an IList, where each Hashtable represents the row of a dynamically executed SQL query. For example, the List might contain the following records/...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

How to filter duplicate list items

i have list of items IList with data that looks list this: GenId TestMode 1 0 1 1 3 0 3 1 4 NULL 2 NULL i want to remove the index ...

C# Grouping/Sorting a Generic List<> using LINQ

Im looking to group and sort a Generic List<>. I have a list of objects representing files and each of these objects has a FileName, FileType and FileDate property. FileType is defined as an ...