多集SQL转换 [英] Multi Set SQL translation

查看:50
本文介绍了多集SQL转换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿所有人,



我有一个SQL程序执行连接以返回一堆对象和一些辅助存储过程执行,这将填满下一个结果主类中的引用对象。



一切都很好,但当我做一个连接返回主类和引用类时,我正在尝试下一步结果并填写对象,但没有运气。我尝试了很多东西但似乎没什么用。任何帮助都会很棒,因为我希望尽量减少前往DB的行程。



下面的一些示例代码

Hey Everyone,

I have a SQL procedure that does a join to return a bunch of objects and some secondary stored procedure executions that will fill up next results of the reference objects in the main class.

Everything is working great, but when I do a join to return the main class and reference class, I am trying to do next results and fill up the object but without luck. I have tried multiple things but nothing seems to work. Any help would be great as I would like to minimize the trips to the DB.

Some of the example code below

//levelstamp - reference class pulled in the main SQL
if (reader.NextResult())
{
   if (returnLevel.levelStamps == null)
      returnLevel.levelStamps = new List<levelstamp>();

   returnLevel.levelStamps = reader.ToLevelStampList();
}

//method
public static List<levelstamp> ToLevelStampList(this IDataReader dataReader)
{
   var returnList = new List<levelstamp>();
   while (dataReader.Read())
   {
      LevelStamp levelStamps = new LevelStamp()
      {
         LevelStampApplyPreferences = Boolean.Parse(dataReader["LevelStampApplyPreferences"].ToString()),
         LevelId = Int32.Parse(dataReader["LevelId"].ToString()),
         LevelStampIsActive = Boolean.Parse(dataReader["LevelStampIsActive"].ToString()),
         StampId = Int32.Parse(dataReader["StampId"].ToString()),
         LevelStampSortOrder = Int32.Parse(dataReader["LevelStampSortOrder"].ToString()),
         stamp = dataReader.ToStampObject() //call to stamp object
      };

      returnList.Add(levelStamps);
   }
   return returnList;
}





当从LevelStamp存储过程中调用戳记时,主存储过程会拉出levelstamp类,所以在essensce中,主存储proc填充基类,然后调用它的辅助存储过程执行来填充基类中的levelstamp,而store proc调用另一个存储过程来填充标记类



从下面的评论中复制的其他信息

调用此方法时,它超出索引范围



The levelstamp class is pulled by the main store procedure while the stamp is called from the LevelStamp stored proc, so in essensce, the main store proc fills up the base class, then its secondary stored proc execution are called to fill up the levelstamp which lives in the base class, and that store proc calls another stored proc to fill up the stamp class

additional information copied from comment below
when this method is called, it is outside of the Index range

public static Stamp ToStampObject(this IDataReader dataReader)
{
   Stamp stamp = null;
   while (dataReader.Read())
   {
      stamp = new Stamp()
      {
         //assign content
      };
   }
   return stamp;
}

推荐答案

这篇关于多集SQL转换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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