简体   繁体   中英

Calling user-defined database functions

Is this possible? I mean, I'm basically looking to do the following...

I have created a function already in my database (although if there's a way to create it using code first migrations, that's fine by me too) called GetPlayerPosition that accepts 1 parameter (an integer representing a Player ID).

I'm looking to do something like this with LINQ in my MVC code:

from p in db.Players
select new { p.PlayerId, GetPlayerPosition(p.PlayerId)};

I know I can't just simply do this, unfortunately (at least not without someway of getting EF to recognize this function), but I've tried hunting around for a while to find a way to do this and I'm just spinning my wheels. Any help is appreciated.

您可以使用Code First Functions约定从Code First(EF 6.1.1)调用存储过程,TVF和标量UDF。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM