Use of ModelDefinedFunctions

Hello,

I have come up with an issue i would like to get some understanding for. When I bring up LinqPad and load my query it is
originally connected to .

The DLLname code contains the following which is required for the function
[ModelDefinedFunction(nameof(FY), "", @(Year(AddMonths(SomeDate,6)) ))]

However, when I run the query in LinqPad I get an error as follows
The specified method 'Int32 FY(SomeDate)' on the type '.ModelDefinedFunctions' cannot be translated into a LINQ to Entities st...

If I change that line in the DLLname source code to the following and recompile, it works
[ModelDefinedFunction(nameof(FY), "CodeFirstNamespace", @(Year(AddMonths(SomeDate,6)) ))]

I would like to avoid this duality. Can anyone explain why this is happening and how to avoid it (have the same code work in both cases which is what I expect)

Thank you.

Best,
Charly

Sign In or Register to comment.