Imagine I have a stored procedure like so:
想象一下,我有一个像这样的存储过程:
create proc Foo
@num1 int,
@num2 int,
@num3 int
as
select @num1+@num2 +@num3
If I import the stored procedure into EF and I get a method with 3 parameters, I can map the result to an entity, but how do I get EF to take an entity as parameter, so that I have a method with just 1 parameter?
如果我将存储过程导入EF并获得一个包含3个参数的方法,我可以将结果映射到实体,但是如何让EF将实体作为参数,以便我有一个只有1个参数的方法?
1 个解决方案
#1
3
You should be able to do this with an extension method:
您应该可以使用扩展方法执行此操作:
public static class DbContextExtensions
{
public static SomeType DoTheFoo(this DbContext context,Foo foo)
{
return context.ImportedSproc(foo.num1, foo.num2, foo.num3);
}
}
#1
3
You should be able to do this with an extension method:
您应该可以使用扩展方法执行此操作:
public static class DbContextExtensions
{
public static SomeType DoTheFoo(this DbContext context,Foo foo)
{
return context.ImportedSproc(foo.num1, foo.num2, foo.num3);
}
}