コード例 #1
0
        public static IList FindList(ObjectInfo state, String sql)
        {
            IList       results   = new ArrayList();
            IDataReader rd        = null;
            Hashtable   hashtable = new Hashtable();
            IDbCommand  command   = DataFactory.GetCommand(sql, DbContext.getConnection(state.EntityInfo));

            try {
                rd = command.ExecuteReader();
                while (rd.Read())
                {
                    IDataRecord record = rd;
                    Fill_EntityProperty_Ids(record, state.Includer.EntityPropertyList, ref hashtable);

                    int    id    = Convert.ToInt32(record["Id"]);
                    Object cache = ObjectPool.FindOne(state.EntityInfo.Type, id);

                    if (cache != null)
                    {
                        results.Add(cache);
                    }
                    else
                    {
                        results.Add(FillUtil.Populate(record, state));
                    }
                }
            }
            catch (Exception ex) {
                logger.Error("sql=>" + sql);
                logger.Error(ex.Message);
                logger.Error(ex.StackTrace);
                throw ex;
            }
            finally
            {
                if (command.Connection.State != ConnectionState.Closed)
                {
                    command.Connection.Close();
                    command.Connection.Dispose();
                    OrmHelper.clostCount++;
                    LogManager.GetLogger("Class:System.ORM.Operation.EntityPropertyUtil Method:FindList").Info("数据库连接已关闭【" + OrmHelper.clostCount + "】");
                }
                OrmHelper.CloseDataReader(rd);
            }


            if (results.Count == 0)
            {
                return(results);
            }
            return(setEntityProperty(state, results, hashtable));
        }
コード例 #2
0
 private static void ResolveOneType(MappingClass map, Type t)
 {
     map.TypeList.Add(t.FullName, t);
     //if (!t.IsAbstract && ( t.IsSubclassOf( typeof( ObjectBase ) ) || t is IEntity )) {
     //    map.ClassList[t.FullName] = EntityInfo.GetByType( t );
     //    logger.Info( "Loading Type : " + t.FullName );
     //}
     // 1029
     logger.Info("Loading Type : " + t.FullName);
     if (rft.IsInterface(t, typeof(IEntity)) && !OrmHelper.IsEntityBase(t))
     {
         map.ClassList.Add(t.FullName, EntityInfo.GetByType(t));
     }
 }
コード例 #3
0
 //1029
 private static Boolean updateParentInfo(EntityInfo info)
 {
     if (info.Type.BaseType == typeof(Object))
     {
         return(false);
     }
     if (OrmHelper.IsEntityBase(info.Type.BaseType))
     {
         return(false);
     }
     if (info.Type.BaseType.IsAbstract)
     {
         return(false);
     }
     return(true);
 }