private void UpdateAll(Plat_util_CodeBase entity, DbTransaction transaction)
        {
            ArgumentValidator.CheckForNullArgument(entity, "entity");
            ArgumentValidator.CheckForNullArgument(transaction, "transaction");

            PersistentPlat_util_CodeBase Plat_util_CodeBaseEntity = entity as PersistentPlat_util_CodeBase;

            try
            {
                Database  db        = GetDatabaseInstance();
                DbCommand dbCommand = db.GetSqlStringCommand(Plat_util_CodeBaseDAO.SqlUpdate);

                db.AddInParameter(dbCommand, "@CodeBaseGuid", DbType.Guid, Plat_util_CodeBaseEntity.CodeBaseGuid);
                db.AddInParameter(dbCommand, "@CodeBaseCode", DbType.String, Plat_util_CodeBaseEntity.CodeBaseCode);
                db.AddInParameter(dbCommand, "@CodeBaseName", DbType.String, Plat_util_CodeBaseEntity.CodeBaseName);
                db.AddInParameter(dbCommand, "@CodeBaseType", DbType.String, Plat_util_CodeBaseEntity.CodeBaseType);
                db.AddInParameter(dbCommand, "@CodeBaseDesc", DbType.String, Plat_util_CodeBaseEntity.CodeBaseDesc);
                db.AddInParameter(dbCommand, "@OnModuleGuid", DbType.Guid, Plat_util_CodeBaseEntity.OnModuleGuid);
                db.AddInParameter(dbCommand, "@ParentCodeBaseGuid", DbType.Guid, Plat_util_CodeBaseEntity.ParentCodeBaseGuid);
                db.AddInParameter(dbCommand, "@IsActive", DbType.Boolean, Plat_util_CodeBaseEntity.IsActive);
                db.AddInParameter(dbCommand, "@MyMark", DbType.Int32, Plat_util_CodeBaseEntity.MyMark);
                int result = db.ExecuteNonQuery(dbCommand, transaction);

                if (result == 0)
                {
                    throw new EntityNotFoundException();
                }
            }
            catch (Exception ex)
            {
                ExceptionPolicy.HandleException(ex, ExceptionPolicy.DataAccessDefaultPolicy);
            }
        }
        /// <summary>
        /// Get with transaction
        /// </summary>
        public Plat_util_CodeBase Get(object entityId, DbTransaction transaction)
        {
            ArgumentValidator.CheckForNullArgument(entityId, "entityId");
            ArgumentValidator.CheckForNullArgument(transaction, "transaction");

            Plat_util_CodeBase Plat_util_CodeBaseEntity = null;

            try
            {
                Database  db        = GetDatabaseInstance();
                DbCommand dbCommand = db.GetSqlStringCommand(Plat_util_CodeBaseDAO.SqlGet);

                db.AddInParameter(dbCommand, "@CodeBaseGuid", DbType.Guid, entityId);
                using (IDataReader dataReader = db.ExecuteReader(dbCommand, transaction))
                {
                    if (dataReader.Read())
                    {
                        Plat_util_CodeBaseEntity = ReadEntity(dataReader);
                    }
                }
            }
            catch (Exception ex)
            {
                ExceptionPolicy.HandleException(ex, ExceptionPolicy.DataAccessDefaultPolicy);
            }

            return(Plat_util_CodeBaseEntity);
        }
        /// <summary>
        /// Insert
        /// </summary>
        public Plat_util_CodeBase Insert(Plat_util_CodeBase entity)
        {
            ArgumentValidator.CheckForNullArgument(entity, "entity");
            PersistentPlat_util_CodeBase Plat_util_CodeBaseEntity = entity as PersistentPlat_util_CodeBase;

            try
            {
                Database  db        = GetDatabaseInstance();
                DbCommand dbCommand = db.GetSqlStringCommand(Plat_util_CodeBaseDAO.SqlInsert);

                db.AddInParameter(dbCommand, "@CodeBaseGuid", DbType.Guid, Plat_util_CodeBaseEntity.CodeBaseGuid);
                db.AddInParameter(dbCommand, "@CodeBaseCode", DbType.String, Plat_util_CodeBaseEntity.CodeBaseCode);
                db.AddInParameter(dbCommand, "@CodeBaseName", DbType.String, Plat_util_CodeBaseEntity.CodeBaseName);
                db.AddInParameter(dbCommand, "@CodeBaseType", DbType.String, Plat_util_CodeBaseEntity.CodeBaseType);
                db.AddInParameter(dbCommand, "@CodeBaseDesc", DbType.String, Plat_util_CodeBaseEntity.CodeBaseDesc);
                db.AddInParameter(dbCommand, "@OnModuleGuid", DbType.Guid, Plat_util_CodeBaseEntity.OnModuleGuid);
                db.AddInParameter(dbCommand, "@ParentCodeBaseGuid", DbType.Guid, Plat_util_CodeBaseEntity.ParentCodeBaseGuid);
                db.AddInParameter(dbCommand, "@IsActive", DbType.Boolean, Plat_util_CodeBaseEntity.IsActive);
                db.AddInParameter(dbCommand, "@MyMark", DbType.Int32, Plat_util_CodeBaseEntity.MyMark);

                int result = db.ExecuteNonQuery(dbCommand);
            }
            catch (Exception ex)
            {
                ExceptionPolicy.HandleException(ex, ExceptionPolicy.DataAccessDefaultPolicy);
            }

            return(Plat_util_CodeBaseEntity as Plat_util_CodeBase);
        }
 public void Update(Plat_util_CodeBase entity, bool updateAll, DbTransaction transaction)
 {
     if (!updateAll)
     {
         UpdateSome(entity, transaction);
     }
     else
     {
         UpdateAll(entity, transaction);
     }
 }
 public void Update(Plat_util_CodeBase entity, bool updateAll)
 {
     if (!updateAll)
     {
         UpdateSome(entity);
     }
     else
     {
         UpdateAll(entity);
     }
 }
        public void UpdateSome(Plat_util_CodeBase entity)
        {
            try
            {
                ArgumentValidator.CheckForNullArgument(entity, "Plat_util_CodeBase Entity");

                plat_util_CodeBaseDAO.Update(entity, false);
            }
            catch (Exception ex)
            {
                ExceptionPolicy.HandleException(ex, ExceptionPolicy.BusinessLogicDefaultPolicy);
            }
        }
        public Plat_util_CodeBase GetEntity(Guid entityGuid)
        {
            Plat_util_CodeBase entity = null;

            try
            {
                ArgumentValidator.CheckForNullArgument(entityGuid, "Plat_util_CodeBase Guid");

                entity = plat_util_CodeBaseDAO.Get(entityGuid);
            }
            catch (Exception ex)
            {
                ExceptionPolicy.HandleException(ex, ExceptionPolicy.BusinessLogicDefaultPolicy);
            }

            return(entity);
        }
        public Plat_util_CodeBase Insert(Plat_util_CodeBase entity)
        {
            Plat_util_CodeBase newEntity = null;

            try
            {
                ArgumentValidator.CheckForNullArgument(entity, "Plat_util_CodeBase Entity");

                newEntity = plat_util_CodeBaseDAO.Insert(entity);
            }
            catch (Exception ex)
            {
                ExceptionPolicy.HandleException(ex, ExceptionPolicy.BusinessLogicDefaultPolicy);
            }

            return(newEntity);
        }
        private static Plat_util_CodeBase ReadEntity(IDataReader dataReader)
        {
            Plat_util_CodeBase Plat_util_CodeBaseEntity = new Plat_util_CodeBase();
            object             value;


            value = dataReader["CodeBaseGuid"];
            if (value != DBNull.Value)
            {
                Plat_util_CodeBaseEntity.CodeBaseGuid = (Guid?)value;
            }

            value = dataReader["CodeBaseCode"];
            if (value != DBNull.Value)
            {
                Plat_util_CodeBaseEntity.CodeBaseCode = (String)value;
            }

            value = dataReader["CodeBaseName"];
            if (value != DBNull.Value)
            {
                Plat_util_CodeBaseEntity.CodeBaseName = (String)value;
            }

            value = dataReader["CodeBaseType"];
            if (value != DBNull.Value)
            {
                Plat_util_CodeBaseEntity.CodeBaseType = (String)value;
            }

            value = dataReader["CodeBaseDesc"];
            if (value != DBNull.Value)
            {
                Plat_util_CodeBaseEntity.CodeBaseDesc = (String)value;
            }

            value = dataReader["OnModuleGuid"];
            if (value != DBNull.Value)
            {
                Plat_util_CodeBaseEntity.OnModuleGuid = (Guid?)value;
            }

            value = dataReader["ParentCodeBaseGuid"];
            if (value != DBNull.Value)
            {
                Plat_util_CodeBaseEntity.ParentCodeBaseGuid = (Guid?)value;
            }

            value = dataReader["IsActive"];
            if (value != DBNull.Value)
            {
                Plat_util_CodeBaseEntity.IsActive = (Boolean?)value;
            }

            value = dataReader["MyMark"];
            if (value != DBNull.Value)
            {
                Plat_util_CodeBaseEntity.MyMark = (Int32?)value;
            }

            return(Plat_util_CodeBaseEntity);
        }
        private void UpdateSome(Plat_util_CodeBase entity, DbTransaction transaction)
        {
            ArgumentValidator.CheckForNullArgument(entity, "entity");
            ArgumentValidator.CheckForNullArgument(transaction, "transaction");

            PersistentPlat_util_CodeBase Plat_util_CodeBaseEntity = entity as PersistentPlat_util_CodeBase;

            StringBuilder sqlUpdateSome = new StringBuilder();

            sqlUpdateSome.Append("UPDATE dbo.Plat_util_CodeBase SET ");

            PropertyInfo[] propertyInfos        = Plat_util_CodeBaseEntity.GetType().GetProperties();
            Hashtable      propertyValues       = new System.Collections.Hashtable();
            int            columnCountForUpdate = 0;

            foreach (PropertyInfo propertyInfo in propertyInfos)
            {
                if (EntityMapping.ContainsProperty(propertyInfo.Name))
                {
                    object     propertyValue = propertyInfo.GetValue(Plat_util_CodeBaseEntity, null);
                    ORProperty property      = EntityMapping[propertyInfo.Name];
                    if (!property.IsPrimaryKey)
                    {
                        if (!Plat_util_CodeBaseEntity.IsDefaultValue(propertyInfo.Name))
                        {
                            propertyValues[propertyInfo.Name] = propertyValue;

                            sqlUpdateSome.Append(" " + property.ColumnName + " = @" + property.ColumnName + ",");
                            columnCountForUpdate++;
                        }
                    }
                    else
                    {
                        propertyValues[propertyInfo.Name] = propertyValue;
                    }
                }
            }
            if (columnCountForUpdate == 0)
            {
                return;
            }

            sqlUpdateSome.Remove(sqlUpdateSome.Length - 1, 1);
            sqlUpdateSome.Append(" WHERE 1 = 1 ");
            sqlUpdateSome.Append(" AND CodeBaseGuid = @CodeBaseGuid ");

            try
            {
                Database  db        = GetDatabaseInstance();
                DbCommand dbCommand = db.GetSqlStringCommand(sqlUpdateSome.ToString());

                foreach (DictionaryEntry de in propertyValues)
                {
                    ORProperty property = EntityMapping[de.Key.ToString()];
                    db.AddInParameter(dbCommand, "@" + property.ColumnName, property.DatabaseType, de.Value);
                }

                int result = db.ExecuteNonQuery(dbCommand, transaction);

                if (result == 0)
                {
                    throw new EntityNotFoundException();
                }
            }
            catch (Exception ex)
            {
                ExceptionPolicy.HandleException(ex, ExceptionPolicy.DataAccessDefaultPolicy);
            }
        }
        /// <summary>
        /// Update with transaction
        /// </summary>

        public void Update(Plat_util_CodeBase entity, DbTransaction transaction)
        {
            Update(entity, true, transaction);
        }
        /// <summary>
        /// Update
        /// </summary>

        public void Update(Plat_util_CodeBase entity)
        {
            Update(entity, true);
        }