本文介绍了Linq to Sql:具有多个结果集的Proc无法与IMultipleResultset一起使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好.
我有一个存储过程返回3个不同的结果集.我将此存储的proc拖到我的dbml文件中,并希望使用IMultipleResults返回所有3个不同的结果集,但是当我尝试请求第二个和第三个结果集时,由于某种原因,它们仍然仅再次返回第一个结果集.我需要能够检索这些第二个&第三名.
这是我的数据上下文文件中的代码:

Hello.
I have a stored procedure that returns 3 different resultsets. I''m dragging this stored proc into my dbml file and want to return all 3 different resultsets using IMultipleResults, however when I try to request my 2nd and 3rd resultsets, they for some reason, still only return the 1st resultset again. I need to be able to retrieve these 2nd & 3rd results.
Here''s my code in my datacontext file:

[Function(Name="dbo.MyStoredProcName")]
        [ResultType(typeof(InventoryTransactions))]
        [ResultType(typeof(Shipments))]
        [ResultType(typeof(Receipts))]
        public IMultipleResults GetMultipleRs()
        {
            IExecuteResult result = this.ExecuteMethodCall(this, (MethodInfo) MethodInfo.GetCurrentMethod());
            return (IMultipleResults) result.ReturnValue;
        }





然后,我从3种不同的方法之一调用它.下面列出了所有3个.这三个之间的唯一区别是,每个尝试返回一个不同的结果集(InventoryTransactions,Shipments和& Receipts):





Then, I call it from one of 3 different methods. All 3 are listed below. The only difference between the 3 is each one attempts to return a different resultset (InventoryTransactions, Shipments, & Receipts):

public List<inventorytransactions> GetIlsInventoryTransactions(DateTime startDate, DateTime endDate)
        {
            List<inventorytransactions> transactions;

            using (IlsDataContext dc = _conn.GetIlsTransactionContext())
            {
                IMultipleResults ret = dc.GetMultipleRs();
                transactions = (from t in ret.GetResult<InventoryTransactions>()
                                where t.DateTimeStamp >= startDate && t.DateTimeStamp < endDate
                                select t).ToList();
            }
            return transactions;
        }

public List<Shipments> GetIlsShipments(DateTime startDate, DateTime endDate)
        {
            List<Shipments> transactions;

            using (IlsDataContext dc = _conn.GetIlsTransactionContext())
            {
                IMultipleResults ret = dc.GetMultipleRs();
                transactions = (from t in ret.GetResult<Shipments>()
                                where t.DateTimeStamp >= startDate && t.DateTimeStamp < endDate
                                select t).ToList();
            }
            return transactions;
        }



public List<Receipts> GetIlsReceipts(DateTime startDate, DateTime endDate)
        {
            List<Receipts> transactions;

            using (IlsDataContext dc = _conn.GetIlsTransactionContext())
            {
                IMultipleResults ret = dc.GetMultipleRs();
                transactions = (from t in ret.GetResult<Receipts>()
                                where t.DateTimeStamp >= startDate && t.DateTimeStamp < endDate
                                select t).ToList();
            }
            return transactions;
        }</inventorytransactions></inventorytransactions>




-------------------------------------------------- ------------------------------
当我调用这3个方法中的任何一个时,所有3个方法仅返回第一个结果集(InventoryTransactions)的数据.知道为什么我不能获得第二和第三名吗?




--------------------------------------------------------------------------------
When I call any of these 3 methods, all 3 only return the data from the 1st resultset (InventoryTransactions). Any idea why I can''t get the 2nd and 3rd ones?
Thanks.

推荐答案


这篇关于Linq to Sql:具有多个结果集的Proc无法与IMultipleResultset一起使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-11 17:56