实体框架代码优先 [英] Entity Framework Code First

查看:78
本文介绍了实体框架代码优先的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Entity Framework Code First方法。使用此方法,我创建了Customer和其他一些实体。

I am using Entity Framework Code First approach.Using this,I have created Customer and some other entities.

现在我想创建一个存储过程'GetCustomers'使用上下文类和传递参数并在集合中获取结果集

Now I want to create a stored procedure 'GetCustomers' using context class and pass parameters and get result set in a collection

它必须返回2个集合,如下所示

it has to return 2 collections as below

create procedure getcustomer @name nvarchar(max ),@ zipcode int

create procedure getcustomer @name nvarchar(max),@zipcode int

as

select 来自客户的ID,姓名,邮政编码,其名称如(@name);

select  id,name,zipcode from Customer where name like (@name );

选择 客户的id,姓名,邮政编码,其中zipcode = @ zipcode

select  id,name,zipcode from Customer where zipcode =@zipcode

 我想使用上下文类创建存储过程'GetCustomers',而不是在DB中手动执行。我需要在下面实现结果:

 I want to create a stored procedure 'GetCustomers' using context class and not manually execute in DB.I need to achieve below results:

1.单独使用名称参数并返回第一个集合

1.Pass name parameter alone and return first collection

2.单独使用zipcode参数并返回第二个集合。

2.Pass zipcode parameter alone and return 2nd collection.

3.使用合并将1和2的结果集合合并到单个集合中

3.Combine result collection of 1 and 2 into a single collection using merge

推荐答案

http://social.msdn.microsoft.com/Forums/en-US/home?forum=adodotnetentityframework

这是你应该发布的地方。

It is where you should post.


这篇关于实体框架代码优先的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆