Javascript Linq帮助需要从sql模型转换为Linq对象模型
我有以下LinqJavascript 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
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#代码竞赛?