Hi,
I am having trouble mapping a SQL Server 2012 scalar function, tried with functions with and without parameters but get exception "No mapping exists from object type <CONTEXT TYPENAME> to a known managed provider native type."
Sample:
create function dbo.MyFunc(@p1 int)
returns uniqueidentifier
as
begin
return newid()
end
Linq statement calling is something like:
context.MyTable.Where(x => x.Id == context.MyFunc(1)).ToList();
Tried this on my context class:
[SqlFunction("MsSql2012", "dbo.MyFunc({0})", ServerSideOnly = true)]
public Guid MyFunc(int p1)
{
throw new NotImplementedException("This function is serverside only");
}
or other variant as:
[SqlFunction("MsSql2012", "MyFunc({0})", ServerSideOnly = true)]
[SqlFunction("MsSql2012", "dbo.MyFunc", ServerSideOnly = true)]
[SqlFunction("MsSql2012", "MyFunc", ServerSideOnly = true)]
[SqlFunction("dbo.MyFunc({0})", ServerSideOnly = true)]
[SqlFunction(ServerSideOnly = true)]
Also tried to play with an SqlExpression but nothing helps.
Can anyone help me on this, table valued functions works fine?