Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Calling SQL Server function without EDMX
Message
 
 
À
30/12/2014 12:20:51
Information générale
Forum:
ASP.NET
Catégorie:
Entity Framework
Versions des environnements
Environment:
C# 4.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01612850
Message ID:
01612854
Vues:
42
I'd like to call the function directly but apparently it's not possible. I think we're using EF6. I'm looking right now into SqlQuery method explained here http://msdn.microsoft.com/en-us/data/jj592907.

>Depending on the version of EF, you can call a stored proc, which can call the function.
>
>
>
>
>>Hi everybody,
>>
>>I'm wondering if there is a way to use SQL Server function (in particular, we have function that calculates age based on the birthday) without using EDMX?
>>
>>I checked this link http://msdn.microsoft.com/en-us/library/vstudio/dd456847(v=vs.100).aspx but wondering if there is any other way.
>>
>>This is what I started to write:
>>
>>
>>  var query = db.Guests.Select(g => new GuestsList
>>            {
>>                LastName = g.LastName,
>>                FirstName = g.FirstName,
>>                BirthDate = g.BirthDate,
>>                Phone = g.Address.AreaCode.Trim() + g.Address.Phone.Trim()
>>               
>>            });
>>
>>We have a SQL Server function dbo.siriusfn_AgeToday(g.birth_date) which I'd like to include into this query.
>>
>>Thanks a lot in advance.
>>
>>UPDATE. Looks like it's not supported in Code First :( http://data.uservoice.com/forums/72025-entity-framework-feature-suggestions/suggestions/1953237-code-first-support-for-user-defined-functions-udf
>>
>>I added 3 votes.
If it's not broken, fix it until it is.


My Blog
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform