sjh37 / EntityFramework-Reverse-POCO-Code-First-Generator

EntityFramework Reverse POCO Code First Generator - Beautifully generated code that is fully customisable. This generator creates code as if you reverse engineered a database and lovingly created the code by hand. It is free to academics (you need a .edu or a .ac email address), not free for commercial use. Obtain your licence from
https://www.reversepoco.co.uk/
Other
711 stars 227 forks source link

Unable to call scalar function #827

Open mmisnerms opened 10 months ago

mmisnerms commented 10 months ago

I am attempting to use a scalar function in a LINQ to entities query.

The tt file is generating an instance method and when I attempt to use it throws the "Don't call this directly. Use LINQ to call the scalar valued function as part of your query" exception. var a = from s in db.Users where s.LastName == "lastname" select new { email = s.Email, number = db.is4_fnScalarValue2(1) };

I changed the method to static and removed from the interface and it is working now.

var a = from s in db.Users where s.LastName == "lastname" select new { email = s.Email, number = ApplicationDbContext.is4_fnScalarValue2(1) };