Beispiel #1
0
 /*this is only for set activebool to false, for physically remove drom table will use direct function from EF*/
 public T SetPreparationEntity <T>(T entity) where T : class
 {
     if (entity != null)
     {
         TypeBantuan tipe           = new TypeBantuan();
         var         propUpdateDate = ColumnPropGet.GetInstance.GetColumnProps <T>(MiscClass.MiscClass.ArrayUpdateDate);
         var         propActiveBool = ColumnPropGet.GetInstance.GetColumnProps <T>(MiscClass.MiscClass.ArrayActiveBool);
         if (propUpdateDate != null)
         {
             if (propUpdateDate.CanWrite)
             {
                 object objUpdateDate = tipe.DictTypes[ColumnPropGet.GetInstance.GetColumnType(propUpdateDate)].GetDefaultValue(false);
                 propUpdateDate.SetValue(entity, objUpdateDate);
             }
         }
         if (propActiveBool != null)
         {
             if (propActiveBool.CanWrite)
             {
                 propActiveBool.SetValue(entity, false);
             }
         }
     }
     return(entity);
 }
        public T SetPreparationEntity <T>(T entity) where T : class
        {
            //update all all field defined in entity ,additonal if forget for updatedate
            TypeBantuan tipe           = new TypeBantuan();
            var         propUpdateDate = ColumnPropGet.GetInstance.GetColumnProps <T>(MiscClass.MiscClass.ArrayUpdateDate);
            var         propUpdateBy   = ColumnPropGet.GetInstance.GetColumnProps <T>(MiscClass.MiscClass.ArrayUpdateBy);

            if (propUpdateDate != null)
            {
                if (propUpdateDate != null)
                {
                    if (propUpdateDate.CanWrite)
                    {
                        if (ColumnPropGet.GetInstance.GetIsNullDatetime <T>(propUpdateDate, entity))
                        {
                            object objUpdateDate = tipe.DictTypes[ColumnPropGet.GetInstance.GetColumnType(propUpdateDate)].GetDefaultValue(false);
                            propUpdateDate.SetValue(entity, objUpdateDate);
                        }
                    }
                    if (propUpdateBy != null)
                    {
                        if (propUpdateBy.CanWrite)
                        {
                            object objpic = ColumnPropSet.GetInstance.SetColumnPicValue <T>(propUpdateBy, entity);
                            propUpdateBy.SetValue(entity, objpic);
                        }
                    }
                }
            }
            return(entity);
        }
Beispiel #3
0
        //update all all field,If forget update data entity, so auto fill from db record
        public T SetPreparationEntity <T>(T entity) where T : class
        {
            var      propIdentity = ColumnPropGet.GetInstance.GetIdentityColumnProps <T>();
            RepoList repo         = new RepoList();

            if (propIdentity != null)
            {
                object             identityID = propIdentity.GetValue(entity);
                List <SearchField> lsf        = new List <SearchField>();
                lsf.Add(new SearchField {
                    Name = propIdentity.Name, Operator = "=", Value = identityID.ToString()
                });
                var checkEntityList     = repo.ListData <T>(lsf);
                var checkEntityListData = (List <T>)checkEntityList.ReturnValue[0].ReturnValue;
                if (checkEntityList != null & checkEntityList.IsSuccessConnection & checkEntityList.IsSuccessQuery
                    & (checkEntityListData).Count > 0)
                {
                    var colNull     = ColumnPropGet.GetInstance.GetPropertyColNullOnly <T>(entity);
                    var checkEntity = checkEntityListData[0];
                    foreach (PropertyInfo itemPropUpdate in colNull)
                    {
                        // update tblEntity
                        var itemPropUpdateValue = itemPropUpdate.GetValue(checkEntity);
                        ColumnPropSet.GetInstance.SetColValue <T>(entity, itemPropUpdate.Name, itemPropUpdateValue);
                    }
                    TypeBantuan tipe           = new TypeBantuan();
                    var         propUpdateDate = ColumnPropGet.GetInstance.GetColumnProps <T>(MiscClass.MiscClass.ArrayUpdateDate);
                    var         propUpdateBy   = ColumnPropGet.GetInstance.GetColumnProps <T>(MiscClass.MiscClass.ArrayUpdateBy);
                    if (propUpdateDate != null)
                    {
                        if (propUpdateDate.CanWrite)
                        {
                            if (ColumnPropGet.GetInstance.GetIsNullDatetime <T>(propUpdateDate, entity))
                            {
                                object objUpdateDate = tipe.DictTypes[ColumnPropGet.GetInstance.GetColumnType(propUpdateDate)].GetDefaultValue(false);
                                propUpdateDate.SetValue(entity, objUpdateDate);
                            }
                        }
                    }
                    if (propUpdateBy != null)
                    {
                        if (propUpdateBy.CanWrite)
                        {
                            object objpic = ColumnPropSet.GetInstance.SetColumnPicValue <T>(propUpdateBy, entity);
                            propUpdateBy.SetValue(entity, objpic);
                        }
                    }
                }
            }
            return(entity);
        }
Beispiel #4
0
        public T SetPreparationEntity <T>(T entity) where T : class
        {
            TypeBantuan tipe           = new TypeBantuan();
            var         propIdentity   = ColumnPropGet.GetInstance.GetIdentityColumnProps <T>();
            var         propActiveBool = ColumnPropGet.GetInstance.GetColumnProps <T>(MiscClass.MiscClass.ArrayActiveBool);
            var         propInsertDate = ColumnPropGet.GetInstance.GetColumnProps <T>(MiscClass.MiscClass.ArrayInsertDate);
            var         propInsertBy   = ColumnPropGet.GetInstance.GetColumnProps <T>(MiscClass.MiscClass.ArrayInsertBy);

            if (propIdentity != null)
            {
                if (propIdentity.CanWrite)
                {
                    object objID = tipe.DictTypes[ColumnPropGet.GetInstance.GetColumnType(propIdentity)].GetDefaultValue(false);
                    propIdentity.SetValue(entity, objID);
                }
            }
            if (propActiveBool != null)
            {
                if (propActiveBool.CanWrite)
                {
                    object objActiveBool = tipe.DictTypes[ColumnPropGet.GetInstance.GetColumnType(propActiveBool)].GetDefaultValue(false);
                    propActiveBool.SetValue(entity, objActiveBool);
                }
            }
            if (propInsertDate != null)
            {
                if (propInsertDate.CanWrite)
                {
                    if (ColumnPropGet.GetInstance.GetIsNullDatetime <T>(propInsertDate, entity))
                    {
                        object objInsertDate = tipe.DictTypes[ColumnPropGet.GetInstance.GetColumnType(propInsertDate)].GetDefaultValue(false);
                        propInsertDate.SetValue(entity, objInsertDate);
                    }
                }
            }
            if (propInsertBy != null)
            {
                if (propInsertBy.CanWrite)
                {
                    object objpic = ColumnPropSet.GetInstance.SetColumnPicValue <T>(propInsertBy, entity);
                    propInsertBy.SetValue(entity, objpic);
                }
            }
            return(entity);
        }