【发布时间】:2018-01-28 20:21:06
【问题描述】:
我在我的应用程序中使用代码优先的方法。我已经使用该方法生成了实体(表)。现在我想通过代码创建一个存储过程。当我尝试迁移选项并且失败时,有人可以指导我。
我正在使用实体框架代码优先方法。使用此方法,我创建了客户和其他一些实体。
现在我想使用上下文类创建一个存储过程“GetCustomers”并传递参数并在集合中获取结果集
它必须返回 2 个集合,如下所示
创建过程 getcustomer @name nvarchar(max),@zipcode int
作为
select id,name,zipcode from Customer where name like (@name);
选择 id,name,zipcode from Customer where zipcode =@zipcode
我想使用上下文类创建一个存储过程“GetCustomers”,而不是在 DB 中手动执行。我需要达到以下结果:
1.单独传递name参数,返回第一个集合
2.单独传递邮政编码参数并返回第二个集合。
3.使用合并将1和2的结果集合合并到一个集合中
【问题讨论】:
标签: entity-framework stored-procedures ef-code-first