开发者

LINQ provider- mapping an object through an array indexer?

开发者 https://www.devze.com 2023-02-19 03:16 出处:网络
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\'

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?

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号