Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/267.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 具有多个连接的复杂LINQ查询语法错误_C#_Linq_Asp.net Mvc 4_Join - Fatal编程技术网

C# 具有多个连接的复杂LINQ查询语法错误

C# 具有多个连接的复杂LINQ查询语法错误,c#,linq,asp.net-mvc-4,join,C#,Linq,Asp.net Mvc 4,Join,我有一个连接两个列表并创建一个新对象列表的查询,我想用一个新的连接来增强这一点,但到目前为止,我尝试的一切似乎都不起作用 名单如下: IList<Content> result IList<Content> resultDefault Resharper给出了一个“无法推断方法的类型参数”。很遗憾,我不能复制粘贴那个 正确的联接语法是什么?创建组时,会丢失以前的引用。在这一点上,你不再有x,这都是关于g和z的,所以我的查询是不可能的?我不会这么说。请看一下这里的示例:。

我有一个连接两个列表并创建一个新对象列表的查询,我想用一个新的连接来增强这一点,但到目前为止,我尝试的一切似乎都不起作用

名单如下:

IList<Content> result
IList<Content> resultDefault
Resharper给出了一个“无法推断方法的类型参数”。很遗憾,我不能复制粘贴那个


正确的联接语法是什么?

创建组时,会丢失以前的引用。在这一点上,你不再有
x
,这都是关于
g
z
的,所以我的查询是不可能的?我不会这么说。请看一下这里的示例:。分组时可以创建自定义对象。
IEnumerable<ContentItem> joined = from x in resultDefault
join y in result on new { x.ResourceKey, x.ResourceType, x.Application } equals new { y.ResourceKey, y.ResourceType, y.Application } into g
from o in g.DefaultIfEmpty(new Content()
{
  Id = 0,
  CultureCode = cultureCode,
  ResourceKey = x.ResourceKey,
  ResourceType = x.ResourceType,
  ResourceValue = String.Empty
})

where
 (
     resourcesJoin == ResourcesJoin.All ||
     (resourcesJoin == ResourcesJoin.Translated && o.ResourceValue != String.Empty) ||
     (resourcesJoin == ResourcesJoin.NotTranslated && o.ResourceValue == String.Empty)
  )
  &&
  (
     string.IsNullOrEmpty(searchString) ||
     (
         x.ResourceKey.ContainsIgnoreCase(searchString) ||
         x.ResourceValue.ContainsIgnoreCase(searchString) ||
         o.ResourceValue.ContainsIgnoreCase(searchString)
     )
  )
select new ContentItem(o, x);
IList<DifferentContent> resultCollection;
IEnumerable<ContentItem> joined = from x in resultDefault
    join y in result on new { x.ResourceKey, x.ResourceType, x.Application } equals new { y.ResourceKey, y.ResourceType, y.Application } into g
    from o in g.DefaultIfEmpty(new Content()
    {
      Id = 0,
      CultureCode = cultureCode,
      ResourceKey = x.ResourceKey,
      ResourceType = x.ResourceType,
      ResourceValue = String.Empty
    })
    join z in resultCollection on new { x.ResourceKey, x.ResourceType, x.Application, x.CultureCode } equals new { z.ResourceKey, z.ResourceType, z.Application, defaultCultureCode } into m
    from s in m.DefaultIfEmpty(new DifferentContent()
      {
          Id = 0,
          CultureCode = defaultCultureCode,
          ResourceKey = x.ResourceKey,
          ResourceType = x.ResourceType,
          ResourceValue = string.Empty
      })
    where
     (
         resourcesJoin == ResourcesJoin.All ||
         (resourcesJoin == ResourcesJoin.Translated && o.ResourceValue != String.Empty) ||
         (resourcesJoin == ResourcesJoin.NotTranslated && o.ResourceValue == String.Empty)
      )
      &&
      (
         string.IsNullOrEmpty(searchString) ||
         (
             x.ResourceKey.ContainsIgnoreCase(searchString) ||
             x.ResourceValue.ContainsIgnoreCase(searchString) ||
             o.ResourceValue.ContainsIgnoreCase(searchString)
         )
      )
    select new ContentItem(o, x, s);
 The type of one of the expressions in the join clause is incorrect.  Type inference failed in the call to 'GroupJoin'.