Beispiel #1
0
        /// <summary>
        /// 读取信息
        /// </summary>
        /// <param name="reader"></param>
        /// <returns></returns>
        public EntityBase LoadFromReader(IDataReader reader)
        {
            IDBAdapter dbAdapter = _entityInfo.DBInfo.CurrentDbAdapter;

            EntityBase objRet = null;

            objRet = _entityInfo.CreateSelectProxyInstance() as EntityBase;

            foreach (AliasReaderMapping readMapping in _lstReaderMapping)
            {
                int index = readMapping.ReaderIndex;
                EntityPropertyInfo info = readMapping.PropertyInfo;
                if (!reader.IsDBNull(index))
                {
                    dbAdapter.SetObjectValueFromReader(reader, index, objRet, info, readMapping.NeedChangeType);
                }
            }
            foreach (KeyValuePair <string, AliasTableMapping> keyPair in _dicChildTables)
            {
                AliasTableMapping childMapping = keyPair.Value;
                object            child        = childMapping.LoadFromReader(reader);
                if (childMapping.MappingInfo.IsParent)
                {
                    childMapping.MappingInfo.SetValue(objRet, child);
                }
                //else if ((!childMapping.MappingInfo.IsParent) && (child != null))
                //{
                //    IList lst = childMapping.MappingInfo.GetValue(objRet) as IList;
                //    if (lst == null)
                //    {
                //        lst = Activator.CreateInstance(childMapping.MappingInfo.FieldType) as IList;
                //        childMapping.MappingInfo.SetValue(objRet, lst);
                //    }
                //    lst.Add(child);
                //}
            }
            return(objRet);
        }
 /// <summary>
 /// 从Reader读取
 /// </summary>
 /// <param name="reader"></param>
 /// <param name="hasValue"></param>
 /// <returns></returns>
 public object LoadFromReader(IDataReader reader)
 {
     return(_primaryTable.LoadFromReader(reader));
 }