[Entity Framework] 如何加入SQL server Function

有時寫code時, 有需要call 到SQL server 內的Function 但卻不能順利進行. 除了DataContext.ExecuteCommand()進行外, 還可以透過DbFunctionAttribute使用.

使用時EntityFramework 會直接call SQL server function 並return 其value.

[DbFunction("hkcfDataModel.Store", "GetDonorName")]
public string GetDonorName(string nvchCompanyName, string nvchTcFirstName, string nvchTcLastName, string nvchTcPrefix, string vchEnFirstName, string vchEnLastName, string vchEnPrefix, string vchLang)
{
    throw new NotSupportedException("Direct call does not supported.");
}

 

About C.H. Ling 262 Articles
a .net / Java developer from Hong Kong and currently located in United Kingdom. Thanks for Google because it solve many technical problems so I build this blog as return. Besides coding and trying advance technology, hiking and traveling is other favorite to me, so I will write down something what I see and what I feel during it. Happy reading!!!

Be the first to comment

Leave a Reply

Your email address will not be published.


*


This site uses Akismet to reduce spam. Learn how your comment data is processed.