开发者

Linq-to-SQL: property without a storage column

开发者 https://www.devze.com 2023-01-21 22:46 出处:网络
hey, there, is there any way to ass a NON DB property to a Linq-to-SQL class? (etc calculated fields), I\'m getting an error when try开发者_如何学编程ingLinq2Sql generates your entities as partial cla

hey, there, is there any way to ass a NON DB property to a Linq-to-SQL class? (etc calculated fields), I'm getting an error when try开发者_如何学编程ing


Linq2Sql generates your entities as partial classes. This makes it easy to extend these classes yourself without modifying the code generated by L2S (which is a bad idea since it will be overwritten if you update your model and regenerate.)

Just find the partial class definition and create a new source file where you declare the same partial class. Inside that new class, add the property or methods that you want to use in your code but Linq2Sql will not have any knowledge of.

0

精彩评论

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