Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/432.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/272.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
Javascript Linq帮助需要从sql模型转换为Linq对象模型_Javascript_C#_Json_Linq_Linq.js - Fatal编程技术网

Javascript Linq帮助需要从sql模型转换为Linq对象模型

Javascript Linq帮助需要从sql模型转换为Linq对象模型,javascript,c#,json,linq,linq.js,Javascript,C#,Json,Linq,Linq.js,我有以下Linq from x in Enumerable.Range(refx - 1, 3) from y in Enumerable.Range(refy - 1, 3) where (x >= 0 && y >= 0) && (x < array.GetLength(0) && y < array.GetLength(1)) && !(x == refx && y == r

我有以下Linq

from x in Enumerable.Range(refx - 1, 3)
from y in Enumerable.Range(refy - 1, 3)
where
  (x >= 0 && y >= 0) &&
  (x < array.GetLength(0) && y < array.GetLength(1)) &&
  !(x == refx && y == refy)
select new Location(x,y)
可枚举范围中x的
(参考文献-1,3)
从可枚举范围中的y开始(参考-1,3)
哪里
(x>=0&&y>=0)&&
(x
我想有在其他Linq格式相同

大概

Enumerable.Range(refx-1,3)
.Select(x)
.Range(refy - 1, 3)
.Select(y)
.Where(x >= 0 && y >= 0) &&
      (x < array.GetLength(0) && y < array.GetLength(1)) &&
      !(x == refx && y == refy)
.Select new Location(x,y)
可枚举范围(参考文献-1,3)
.选择(x)
.范围(参考文献-1、3)
.选择(y)
。其中(x>=0&&y>=0)&&
(x
我知道上面是错的,但我想要第二种格式的第一种, 任何帮助都是非常感激的


另外,如果有人擅长linq.js,那么将第一个转换为linq.js将非常棒

这相当于:

    var set = Enumerable.Range(refx - 1, 3)
            .Select(x => Enumerable.Range(refy - 1, 3)
                .Where(y => (x >= 0 && y >= 0) &&
                    (x < array.GetLength(0) && y < array.GetLength(1)) &&
                    !(x == refx && y == refy))
                .Select(y => new Location(x, y)))
            .SelectMany(x => x);
var set=Enumerable.Range(参考文献-1,3)
.选择(x=>Enumerable.Range)(参考文献-1,3)
。其中(y=>(x>=0&&y>=0)&&
(x新位置(x,y)))
.SelectMany(x=>x);

我想你要找的是Zip

Enumerable.Range(refx - 1, 3).Zip(Enumerable.Range(refy - 1, 3),
    (x, y) => new Tuple<int, int>(x, y))
    .Where(t => (t.Item1 >= 0) && (t.Item2 <= 0)
    && (t.Item1 < array.GetLength(0)) && (t.Item2 < array.GetLength(1))
    && !((t.Item1 == refx) && (t.Item2 == refy)))
    .Select(t => new Location(t.Item1, t.Item2));
Enumerable.Range(refx-1,3).Zip(Enumerable.Range(refy-1,3)),
(x,y)=>新元组(x,y))
其中(t=>(t.Item1>=0)和&(t.Item2新位置(t.Item1,t.Item2));

Fwiw,ReSharper将自动为您执行此操作。谢谢柯克·ReSharper完成了此任务:)是否有模糊C#代码竞赛?