代码之家  ›  专栏  ›  技术社区  ›  Saif Khan

亚音速2.2支持懒惰拉丁

  •  1
  • Saif Khan  · 技术社区  · 16 年前

    亚音速2.2是否支持延迟加载?我可以延迟加载对象的属性吗?如果是,我在哪里可以找到有关这个的信息?

    1 回复  |  直到 16 年前
        1
  •  0
  •   Aristos    16 年前

    亚音速2.2不支持延迟加载。

    所有加载到呼叫中并插入到列表中的数据。

    怎么会是个好主意呢?

    这里是加载数据的点。

        /// <summary>
        /// Loads the collection and leaves the IDataReader open.
        /// </summary>
        /// <param name="dataReader">The data reader.</param>
        public void Load(IDataReader dataReader)
        {
            while(dataReader.Read())
            {
                ItemType item = new ItemType();
                item.Load(dataReader);
                Add(item);
            }
        }
        /// <summary>
        /// Loads the collection by iterating through the rows in the supplied DataTable.
        /// </summary>
        /// <param name="dataTable">The data table.</param>
        public void Load(DataTable dataTable)
        {
            foreach(DataRow dr in dataTable.Rows)
            {
                ItemType item = new ItemType();
                item.Load(dr);
                Add(item);
            }
        }