Encoding in linq/entity framework
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.
精彩评论