开发者

Encoding in linq/entity framework

开发者 https://www.devze.com 2022-12-10 21:36 出处:网络
I\'m working on a lega开发者_开发知识库cy where some fields uses special encodings. Is it somehow possible to set an decode the fields in the linq instead of doing as I\'m doing now:

I'm working on a lega开发者_开发知识库cy where some fields uses special encodings. Is it somehow possible to set an decode the fields in the linq instead of doing as I'm doing now:

XisoEncoding enc = new XisoEncoding()

var q = from b in ent.Basket
            where b.ID == 22038
            select b;

Basket basket = query.First();
basket.STOMAN_MESSAGE = enc.DecodeString(basket.STOMAN_MESSAGE);

.....


Entity classes are defined as partial classes. You could add a new property to the Basket class, for example DecodedStomanMessage, which returns the decoded message.

I would not modify the STOMAN_MESSAGE property itself, since this will mark the entity as modified, and you could end up sending the decoded version back to the database.

0

精彩评论

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