LINQ provider- mapping an object through an array indexer?
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 _exampleLanguageModerationL开发者_开发知识库ist 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?
You're testing m[Language.English]
against a bool
.
Since you're returning EN or FR.. shouldn't the return type of your indexer be bool
?
精彩评论