我有一个数据库,看起来像这样:
[ID] [5TypeOfIntegers] [TEXT] [name ID]5TypeOfIntegers有5个整数。(1- 5)。
我想从我的5种类型(值2和4)中获取2个值,如果name ID匹配,则获取数据,如果name ID不匹配,则获取其他3个值(值1,3和5)。
示例:
[ID] [5TypeOfIntegers] [TEXT] [nameID] = User logged is 1.
0 2 bla 1 - GRAB DATA (Type is correct and user is correct))
1 3 bla 1 - DONT GRAB DATA (Type is wrong and user is correct)
2 3 bla 2 - GRAB DATA (Different ID from the person logged in, Type is correct)我对LINQ代码的看法是这样的:
db.Where(e => e.nameID == 1).Select( e => e.5TypeOfIntegers == 2 && e.5TypeOfIntegers == 4)但在那之后,我有点迷失了,这甚至不起作用。:(
谢谢你的帮助!
发布于 2021-07-01 12:12:04
所以,换句话说,你想要"not(type 1,3,5 and nameId = currentlyloggedin)“
var types = new[]{1,3,5};
context.Whatever.Where(x => !(types.Contains(x.Type) && x.UserId == currentlyLoggedInUserId));https://stackoverflow.com/questions/68201741
复制相似问题