开发者

How to create a Store Expression for entity framework

I have this.

var ViewModel = repGeneric.GetListOf<CompanyContact>(p => p.CompanyID == 1).Select(s => new ContactViewModel()
            {
                ContactType = _db.ContactTypeTexts.FirstOrDefault(p => p.ID == s.Contact.ContactType.ID).Txt
            });

I would like to put this piece of code

_db.ContactTypeTexts.FirstOrDefault(p => p.ID == s.Contact.ContactType.ID).开发者_如何学GoTxt

in a function.

How can I do that.? Any Idea. I Try but that's give me this error :

LINQ to Entities does not recognize the method 'System.String GetTxt()' method, and this method cannot be translated into a store expression.

Thanks


Try Model-Defined Function like it is described in this blog article by Julie Lerman.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜