SQL到Linq(存储过程) [英] SQL to Linq (stored procedure)

查看:63
本文介绍了SQL到Linq(存储过程)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我有一个存储过程:

Hi everyone,

I have a stored procedure:

create procedure sp_proc1 @obj_code
as begin select * from employee where @obj_code=obj_code



它返回几个记录.我希望在Windows应用程序中使用Linq将这些记录放入数据表中:



It returns several records. I want this with Linq in my Windows application to put these records in a data table:

testDatacontext db=new testDatacontext();
var results=db.sp_proc1(melk_id);
for each(sp_proc1result result  in result)
{
  //??????????????????????????????
}



如何将检索到的数据放在数据表中?



How can I put the retrieved data in a data table?

推荐答案

我在这里猜测,是基于我上次查看的LINQ To SQL培训中所记的内容周....

我认为您可以创建一个执行"select * from results"的DataAdapter 并使用其Fill(table)方法填充该表.在我看来,LINQ应该能够处理这个问题,尽管我不知道您必须首先指定多少新表的设计.那些更精通此技术的人可以提供我的快速访问内存中还没有的实现细节. (我真的很想知道我是否正确:cool:.)
I''m guessing here, based on what I remember from some LINQ To SQL training I viewed last week....

I think you could create a DataAdapter that does a "select * from results" and use its Fill(table) method to populate the table. It seems to me that LINQ should be able to handle that, although I don''t know how much of the new table''s design you would have to specify first. Those who are more versed in this can provide the implementation details that aren''t yet in my fast-access memory. (I''d really like to know if I got this right :cool:.)


这篇关于SQL到Linq(存储过程)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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