linq,即使我正在过滤条件,子句也返回所有内容
我正在使用C#和Solrnet返回游戏玩家正在玩的游戏列表。
在我的C#代码中,我正在尝试返回Player History
的数据,其中Isplaying
是正确的。
该数据库具有一个适用于iSplaying
的玩家的表(false forse,1,为true 1)。
这是我的代码:
var nodes = GetGamerNodes().Select(MapNode);
Solr.AddRange(nodes);
Solr.Commit();
private static SearchNodes MapNode(GameList node)
{
return new SearchNodes {
Id = node.Id.ToString(),
GameTitle = node.Title,
Story = node.Story,
Published = node.Game.Published,
PlayerHistory= node.Players.Where(e => e.Player.Current.IsPlaying).Select(e => e.Player.Name).ToArray()
};
}
Player History
是iCollection
在我的模型中,iSplaying
是这样定义的:
public> public virtual virtual virtual bool iSplay {get;放; }
,
但是它正在返回player History
全部数据的数据,而不管iSplaying
的值如何。
我做错了吗?
谢谢!
I am using c# and SolrNet to return a list of games that gamers are playing.
In my c# code, I am trying to return data for PlayerHistory
, where IsPlaying
is true.
The database has a table for Players with a bit column (0 for false, 1 for true) for IsPlaying
.
Here is my code:
var nodes = GetGamerNodes().Select(MapNode);
Solr.AddRange(nodes);
Solr.Commit();
private static SearchNodes MapNode(GameList node)
{
return new SearchNodes {
Id = node.Id.ToString(),
GameTitle = node.Title,
Story = node.Story,
Published = node.Game.Published,
PlayerHistory= node.Players.Where(e => e.Player.Current.IsPlaying).Select(e => e.Player.Name).ToArray()
};
}
PlayerHistory
is an ICollection
In my model, IsPlaying
is defined like this:
public virtual bool IsPlaying { get; set; }
But it is returning PlayerHistory
data for everything regardless of the value of IsPlaying
.
Am I doing something wrong?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是一个小技巧,有时对我有帮助。
对我有用的是做一个这样的临时谓词:
然后,当您进行此替换时...
...它为您提供了可以设置断点并逐步进行的东西,以帮助您确定失败的LINQ中发生的事情询问。希望这很有帮助!
Here's a little trick that has helped me at times like these.
What works for me is to make a temporary predicate like this:
and then when you do this replacement...
... it gives you something you can set breakpoints on and step through to help you determine exactly what's going on in the failing Linq query. Hope this is helpful!