LINQ 提供程序 - 通过数组索引器映射对象?
我有一个课程,语言调节。它包含多种语言的布尔值,显示它们是否经过审核。我已经实现了一个索引器,允许我通过我命名为语言的枚举进行选择。就像这样:
public class LanguageModeration
{
public ModerationRecord EN {get;set;}
public ModerationRecord FR {get;set;}
}
public ModerationRecord this[Language l]
{
get
{
if (l == Language.English) return EN;
else return FR;
}
}
我想在 NHibernate LINQ 表达式中使用这种语法(或类似的语法),例如:
from m in _exampleLanguageModerationList where m[Language.English] == false select m
这不起作用,我得到这个:
System.NotSupportedException: Dm.Mvc.Data.SiteObjects.ModerationRecord get_Item(Dm.Mvc.Data.Types.Language)
现在是否可以使用 NHibernate LINQ 做我想做的事情?
I have a class, LanguageModeration. It contains booleans for a number of languages, showing whether they have been moderated or not. I have implemented an indexer, allowing me to select by an Enum I've named Language. Like so:
public class LanguageModeration
{
public ModerationRecord EN {get;set;}
public ModerationRecord FR {get;set;}
}
public ModerationRecord this[Language l]
{
get
{
if (l == Language.English) return EN;
else return FR;
}
}
I'd like to use this syntax (or something similar) in an NHibernate LINQ expression, something like:
from m in _exampleLanguageModerationList where m[Language.English] == false select m
That doesn't work, I get this:
System.NotSupportedException: Dm.Mvc.Data.SiteObjects.ModerationRecord get_Item(Dm.Mvc.Data.Types.Language)
Is it even possible to do what I want with NHibernate LINQ right now?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您正在针对
bool
测试m[Language.English]
。既然您要返回 EN 或 FR.. 索引器的返回类型不应该是
bool
吗?You're testing
m[Language.English]
against abool
.Since you're returning EN or FR.. shouldn't the return type of your indexer be
bool
?