开发者

How to use UDF output as LINQ to SQL entity class property value?

Just starting out with LINQ to SQL (you can probably tell - be gentle).

I'd like to use the value returned by a user-defined function as an entity class property value and have the the value populated when all the other basic (column) fields are loaded.

I know there are ways 开发者_StackOverflowto use the UDF from a L2S query (here, and here), but I'd prefer to have the value automatically loaded.

For example, I'd expect LINQ to SQL to generate SQL similar to this and populate a property on my User entity class called AssociatedRecordCount with the integer value returned by GetAssociatedRecordCount:

SELECT ID, dbo.GetAssociatedRecordCount(ID) As AssociatedRecordCount
FROM Users

Also, I'm using the Visual Studio LINQ to SQL designer.

Thank you!


Try to create a new custom property not associated with the database and call the function (added to the context) in the getter.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜