简体   繁体   English

在使用Linq Join语句时遇到麻烦

[英]Having trouble with a Linq Join statement

So I have the following Linq query: 因此,我有以下Linq查询:

var comb1 = (from m1 in _modified
                     join o1 in _original on m1.custom_field_option_id equals o1.custom_field_option_id
                     from e1 in _existing
                     .Where(row => (m1.custom_field_option_id == row.custom_field_option_id || m1.custom_field_option_id == 0)
                         && row.custom_field_id == m1.custom_field_id).DefaultIfEmpty()
                     select new { m1, o1, e1 }).ToArray();

In List _modifed I have two items. 在清单_modifed我有两项。 In List _original I have one item. 在清单_original我有一项。 The second item in _modified is a new insert record. _modified的第二项是新的插入记录。 _original does not contain this record and nor does _existing . _original不包含此记录,也不存在_existing

The new record is not being included in my combined array. 新记录未包含在我的组合阵列中。 The custom_field_option_id of the new record is currently 0 so I added to my where clause: 新记录的custom_field_option_id当前为0,因此我将其添加到where子句中:

|| m1.custom_field_option_id == 0

But that didn't help. 但这没有帮助。

How do I change this query to include the new record in _modified ? 如何更改此查询以在_modified包括新记录?

unless i am missing sommething: join o1 in _original on m1.custom_field_option_id equals o1.custom_field_option_id is a hard join to whatever is in _original. 除非我缺少某些东西:在m1上的_original中加入o1.custom_field_option_id等于o1.custom_field_option_id是与_original中的任何内容的硬连接。

Could it be that the row is not present because the row is not in _original? 可能是因为该行不在_original中而不存在该行?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM