内存滤波器中的 SubSonic .Filter()
我在使 .Filter() 方法在亚音速下工作时遇到一些问题,并且我不断收到如下错误:
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
Line 36: bool remove = false;
Line 37: System.Reflection.PropertyInfo pi = o.GetType().GetProperty(w.ColumnName);
Line 38: if (pi.CanRead)
Line 39: {
Line 40: object val = pi.GetValue(o, null);
我正在拨打如下所示的电话 - 这是使用它的正确方法吗? 似乎没有关于使用此方法的文档,
NavCollection objTopLevelCol = objNavigation.Where(Nav.Columns.NavHigherID,Comparison.Equals, 0).Filter();
提前致谢
i'm having some issues getting the .Filter() method to work in subsonic, and i'm constantly getting errors like the one below:
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
Line 36: bool remove = false;
Line 37: System.Reflection.PropertyInfo pi = o.GetType().GetProperty(w.ColumnName);
Line 38: if (pi.CanRead)
Line 39: {
Line 40: object val = pi.GetValue(o, null);
i'm making calls like the one below- is this the corrent way to use it? There seems to be no documentation on the use of this method
NavCollection objTopLevelCol = objNavigation.Where(Nav.Columns.NavHigherID,Comparison.Equals, 0).Filter();
thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您筛选的值必须是属性名称,而不是数据库列名称。
您可以尝试以下方法:
或者这里有一个稍微更详细的方法,它基于 .Filter() 方法的自定义覆盖,对我有用。 通过预先显式创建Where,它似乎工作得更好(至少对我来说):
这是覆盖:
SubSonic 2.0实际上并不支持IsMatch函数的In/NotIn,所以这里是定制的版本(在SubSonic\Utility中) 。CS):
The value you filter against needs to be the Property Name, not the database column name.
You might try this:
Or here's a slightly more verbose method that works for me based on custom overrides of the .Filter() method. It seemed to work better (for me at least) by explicitly creating the Where beforehand:
Here's the overrides:
And SubSonic 2.0 doesn't actually support In/NotIn for the IsMatch function, so here's the customized version that does (in SubSonic\Utility.cs):
如果您使用 .net 3.5,您可以使用 lambda 函数来完成此操作:
IF you're using .net 3.5 you could just do this with a lambda function:
过滤器设计用于处理集合 - “objNavigation”是集合吗? 您遇到的问题是列名“NavHigherID”无法满足 Filter() 的条件。
Filter is designed to work on a collection - is "objNavigation" a collection? The problem you're running into is that the criteria for Filter() can't be met with the column name "NavHigherID".
我遇到了同样的问题,尝试像这样进行过滤:
I was having same prob, try doing your filter like this :