Exemplo n.º 1
0
        private List <T> getListData <T>(int IDIdentity, string idReferenceColName) where T : class
        {
            List <SearchField> param = new System.Collections.Generic.List <SearchField>();

            param.Add(new SearchField {
                Name = idReferenceColName, Operator = "=", Value = IDIdentity.ToString()
            });
            RepoList list       = new RepoList();
            var      myList     = list.ListData <T>(param);
            var      myListData = myList.ReturnValue[0].ReturnValue;

            return((myList.IsSuccessConnection & myList.IsSuccessQuery & myListData.Count > 0) ? myListData : null);
        }
Exemplo n.º 2
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);
        }
        private List <T> GetListData <T>(List <int> listIDIdentity, string idReferenceColName) where T : class
        {
            List <SearchField> param = new System.Collections.Generic.List <SearchField>
            {
                new SearchField {
                    Name = idReferenceColName, Operator = "in", Value = listIDIdentity
                }
            };
            RepoList list       = new RepoList();
            var      myList     = list.ListData <T>(param);
            var      myListData = (List <T>)myList.ReturnValue[0].ReturnValue;

            return((myList.IsSuccessConnection & myList.IsSuccessQuery & myListData.Count > 0) ? myListData : null);
        }
Exemplo n.º 4
0
        public bool IsContinueUpdateAfterMultiplePK <T>(T entity, out EFReturnValue returnValue) where T : class
        {
            // if true, continue to next query
            returnValue = new EFReturnValue {
                IsSuccessConnection = false, IsSuccessQuery = false, ErrorMessage = ErrorMessage.EntityCannotBeNull, ReturnValue = null
            };
            bool result = true;

            if (isUsingMultiplePK)
            {
                List <SearchField> lsfMultiplePK = new List <SearchField>();
                bool isMultiple = this.CheckIsMultiplePKUpdate <T>(entity, out lsfMultiplePK);
                if (isMultiple)
                {
                    RepoList repoList = new RepoList();
                    var      cekList  = repoList.ListData <T>(lsfMultiplePK);
                    if (cekList.IsSuccessConnection & cekList.IsSuccessQuery)
                    {
                        if (cekList.ReturnValue.ReturnValue != null)
                        {
                            var dataList = (List <T>)cekList.ReturnValue.ReturnValue;
                            if (dataList != null)
                            {
                                if (dataList.Count >= 1)
                                {
                                    result = false;
                                    var PIdentity = ColumnPropGet.GetInstance.GetIdentityColumnProps <T>();// Identity PK/identity PK like, means ordinary position must set to 0 in database table
                                    foreach (var item in lsfMultiplePK)
                                    {
                                        if (item.Name != PIdentity.Name)
                                        {
                                            multipleErrorMessage += item.Name + " , ";
                                        }
                                    }
                                    multipleErrorMessage += " columns";
                                    returnValue.SetEFReturnValue(returnValue, false, 0, multipleErrorMessage);
                                }
                            }
                        }
                    }
                }
            }
            return(result);
        }
Exemplo n.º 5
0
        public bool IsContinueSaveAfterMultiplePK <T>(T entity, out EFReturnValue returnValue) where T : class
        {
            // if true, continue to next query
            returnValue = new EFReturnValue {
                IsSuccessConnection = false, IsSuccessQuery = false, ErrorMessage = ErrorMessage.EntityCannotBeNull, ReturnValue = null
            };
            bool result = true;

            if (isUsingMultiplePK)
            {
                List <SearchField> lsfMultiplePK = new List <SearchField>();
                bool isMultiple = this.CheckIsMultiplePKSave <T>(entity, out lsfMultiplePK);
                if (isMultiple)
                {
                    RepoList repoList = new RepoList();
                    var      cekList  = repoList.ListData <T>(lsfMultiplePK);
                    if (cekList.IsSuccessConnection & cekList.IsSuccessQuery)
                    {
                        if (cekList.ReturnValue.ReturnValue != null)
                        {
                            var dataList = (List <T>)cekList.ReturnValue.ReturnValue;
                            if (dataList != null)
                            {
                                if (dataList.Count >= 1)
                                {
                                    result = false;
                                    foreach (var item in lsfMultiplePK)
                                    {
                                        multipleErrorMessage += item.Name + ",";
                                    }
                                    multipleErrorMessage += " columns";
                                    returnValue.SetEFReturnValue(returnValue, false, 0, multipleErrorMessage);
                                }
                            }
                        }
                    }
                }
            }
            return(result);
        }