Exemple #1
0
        private void LokDatabaseFunction_SearchFilterChanged(object sender, MyCommonWPFControls.SearchFilterArg e)
        {
            if (e.SingleFilterValue != null)
            {
                if (!e.FilterBySelectedValue)
                {
                    Enum_DatabaseFunctionType type = Enum_DatabaseFunctionType.None;

                    var list = bizDatabaseFunction.GetAllDatabaseFunctions(MyProjectManager.GetMyProjectManager.GetRequester(), e.SingleFilterValue, type);
                    e.ResultItemsSource = list;
                }
                else
                {
                    var id = Convert.ToInt32(e.SingleFilterValue);
                    if (id > 0)
                    {
                        //lokSecondSideEntity.ItemsSource = bizTableDrivedEntity.GetAllEntities();
                        var item = bizDatabaseFunction.GetDatabaseFunction(MyProjectManager.GetMyProjectManager.GetRequester(), id);
                        e.ResultItemsSource = new List <DatabaseFunctionDTO> {
                            item
                        };
                    }
                    else
                    {
                        e.ResultItemsSource = null;
                    }
                }
            }
        }
        public List <DatabaseFunctionDTO> GetDatabaseFunctions(DR_Requester requester, Enum_DatabaseFunctionType type, int databaseID = 0)
        {
            List <DatabaseFunctionDTO> result = new List <DatabaseFunctionDTO>();

            using (var projectContext = new DataAccess.MyProjectEntities())
            {
                //projectContext.Configuration.LazyLoadingEnabled = false;
                IQueryable <DatabaseFunction> listDatabaseFunction;

                if (databaseID == 0)
                {
                    listDatabaseFunction = projectContext.DatabaseFunction;
                }
                else
                {
                    listDatabaseFunction = projectContext.DatabaseFunction.Where(x => x.DBSchema.DatabaseInformationID == databaseID);
                } if (type == Enum_DatabaseFunctionType.Function)
                {
                    listDatabaseFunction = listDatabaseFunction.Where(x => x.Type == (short)Enum_DatabaseFunctionType.Function);
                }
                else if (type == Enum_DatabaseFunctionType.StoredProcedure)
                {
                    listDatabaseFunction = listDatabaseFunction.Where(x => x.Type == (short)Enum_DatabaseFunctionType.StoredProcedure);
                }
                foreach (var item in listDatabaseFunction)
                {
                    result.Add(ToDatabaseFunctionDTO(item, false));
                }
            }
            return(result);
        }
        public List <DatabaseFunctionDTO> GetAllDatabaseFunctions(DR_Requester dR_Requester, string generalFilter, Enum_DatabaseFunctionType type)
        {
            List <DatabaseFunctionDTO> result = new List <DatabaseFunctionDTO>();

            using (var projectContext = new DataAccess.MyProjectEntities())
            {
                IQueryable <DatabaseFunction> listDatabaseFunction;
                listDatabaseFunction = projectContext.DatabaseFunction;
                if (!string.IsNullOrEmpty(generalFilter))
                {
                    listDatabaseFunction = listDatabaseFunction.Where(x => x.FunctionName.Contains(generalFilter));
                }

                if (type == Enum_DatabaseFunctionType.Function)
                {
                    listDatabaseFunction = listDatabaseFunction.Where(x => x.Type == (short)Enum_DatabaseFunctionType.Function);
                }
                else if (type == Enum_DatabaseFunctionType.StoredProcedure)
                {
                    listDatabaseFunction = listDatabaseFunction.Where(x => x.Type == (short)Enum_DatabaseFunctionType.StoredProcedure);
                }
                foreach (var item in listDatabaseFunction)
                {
                    result.Add(ToDatabaseFunctionDTO(item, false));
                }
            }
            return(result);
        }