コード例 #1
0
        protected override void ConfigureEasyQueryOptions(EasyQueryOptions options)
        {
            options.UseManager <EasyQueryManagerSql>();
            options.DefaultModelId   = "NWindSQL";
            options.BuildQueryOnSync = true;

            ConnectionStringSettings connectionSettings = ConfigurationManager.ConnectionStrings["DefaultConnection"];

            if (connectionSettings == null || string.IsNullOrEmpty(connectionSettings.ConnectionString))
            {
                throw new Exception("Fatal error: missing connecting string in web.config file");
            }

            options.UseDbConnection <SqlConnection>(connectionSettings.ConnectionString);

            var path = System.Web.Hosting.HostingEnvironment.MapPath("~/App_Data");

            options.UseModelLoader((_) => new FileModelLoader(path));
            options.UseQueryStore((_) => new FileQueryStore(path));

            // Uncomment this line if you want to load model directly from connection
            // Do not forget to uncomment SqlClientGate registration in WebApiConfig.cs file
            //options.UseDbConnectionModelLoader(config => {
            //    // Ignores Asp.Net Identity tables
            //    config.AddTableFilter((table) => !table.Name.StartsWith("Asp")
            //                                  && table.Name != "IdentityUsers"
            //                                  && table.Name != "__MigrationHistory");

            //    // Ignores Reports table
            //    config.AddTableFilter((table) => table.Name != "Reports");
            //});

            options.UsePaging(30);
        }
コード例 #2
0
        private void InitEasyQuery()
        {
            var options = new EasyQueryOptions();

            EqManager = new EasyQueryManagerSql(options);

            using (var dbContext = ApplicationDbContext.Create())
                EqManager.Model.LoadFromDbContext(dbContext);

            // EasyQueryManagerSql.RegisterDbGate<SqlServerGate>();
            // EqManager.Model.LoadFromConnection(ApplicationDbContext.Create().Database.GetConnection);

            //saving the reference to Customer Country attribute in our model (will be used on RequestList processing)
            _countryAttr = EqManager.Model.EntityRoot.FindAttributeById("Customers.Country");

            //assign query to all visual controls.
            QPanel.Query   = EqManager.Query;
            CPanel.Query   = EqManager.Query;
            SPanel.Query   = EqManager.Query;
            EntPanel.Query = EqManager.Query;

            //setting differnt properties of EasyQuery visual controls
            CPanel.AllowEditCaptions = true;
            CPanel.AllowSorting      = true;
            EntPanel.ShowFilter      = true;
        }
コード例 #3
0
        private void InitEasyQuery()
        {
            var options = new EasyQueryOptions();

            EqManager = new EasyQueryManagerSql(options);

            using (var dbContext = ApplicationDbContext.Create())
                EqManager.Model.LoadFromDbContext(dbContext);

            // How to load from connection
            // EasyQueryManagerSql.RegisterDbGate<SqlServerGate>();
            // EqManager.Model.LoadFromConnection(ApplicationDbContext.Create().Database.GetConnection());

            //query initialization
            EqManager.Query.ConditionsChanged += query_ConditionsChanged;
            EqManager.Query.ColumnsChanged    += query_ColumnsChanged;

            //add handlers for ListRequest and ValueRequest events
            AddHandler(ListXElement.ListRequestEvent, new ListXElement.ListRequestEventHandler(queryPanel_ListRequest));
            AddHandler(SimpleConditionRow.ValueRequestEvent, new ValueRequestEventHandler(queryPanel_CustomValueRequest));

            //some additional configuration of EasyQuery visual controls
            queryPanel.SortEntities = XSortOrder.Ascending;

            columnsPanel.SortEntities   = XSortOrder.Ascending;
            columnsPanel.ShowCheckBoxes = true;
            sortingPanel.SortEntities   = XSortOrder.Ascending;
            entitiesPanel.SortEntities  = XSortOrder.Ascending;

            PanelExport.Visibility = Visibility.Collapsed;

            textBoxEntityFilter.TextChanged += TextBoxEntityFilter_TextChanged;
            entitiesPanel.ItemAdding        += EntitiesPanel_ItemAdding;
        }
コード例 #4
0
        private void InitEasyQuery()
        {
            var options = new EasyQueryOptions();

            EqManager = new EasyQueryManagerSql(options);

            // loads model from DbContext
            EqManager.Model.LoadFromDbContext(ApplicationDbContext.Create());

            // intialize the data model and load it from XML (or JSON) file
            // EqManager.Model.LoadFromJsonFile("Your path");

            //  intialize the data model and load it from connection
            // DbGate.Register<SqlServerGate>();
            // EqManager.Model.LoadFromConnection(ApplicationDbContext.Create().Database.Connection);

            //saving the reference to Customer Country attribute in our model (will be used on RequestList processing)
            _countryAttr = EqManager.Model.EntityRoot.FindAttributeById("Customers.Country");

            //assign query to all visual controls.
            QPanel.Query   = EqManager.Query;
            CPanel.Query   = EqManager.Query;
            SPanel.Query   = EqManager.Query;
            EntPanel.Query = EqManager.Query;

            //setting differnt properties of EasyQuery visual controls
            this.CPanel.AllowEditCaptions = true;
            this.CPanel.AllowSorting      = true;
            this.EntPanel.ShowFilter      = true;
        }
コード例 #5
0
        public OrderController()
        {
            _dbContext = ApplicationDbContext.Create();

            var options = new EasyQueryOptions();

            options.UseEntity((_) => _dbContext.Orders);

            //create EasyQuery manager which generates LINQ queries
            _eqManager = new EasyQueryManagerLinq <Order>(options);
        }
コード例 #6
0
        public OrderController(IServiceProvider services, AppDbContext dbContext)
        {
            this._dbContext = dbContext;

            var options = new EasyQueryOptions(services);

            options.UseEntity((_, __) =>
                              _dbContext
                              .Orders
                              .Include(o => o.Customer)
                              .Include(o => o.Employee)
                              .AsQueryable());

            _eqManager = new EasyQueryManagerLinq <Order>(services, options);
        }
コード例 #7
0
        protected override void ConfigureEasyQueryOptions(EasyQueryOptions options)
        {
            options.UseManager <EasyQueryManagerSql>();
            options.DefaultModelId   = "NWindSQL";
            options.BuildQueryOnSync = true;

            var connectionString = ConfigurationManagerWrapper.GetConnectionString("DefaultConncetion");

            options.UseDbConnection <SqlConnection>(connectionString);

            var path = System.Web.Hosting.HostingEnvironment.MapPath("~/App_Data");

            options.UseModelLoader((_) => new FileModelLoader(path));
            options.UseQueryStore((_) => new FileQueryStore(path));

            options.AddPreExecuteTuner(new SessionPreExecuteTuner());
        }
コード例 #8
0
        protected override void ConfigureEasyQueryOptions(EasyQueryOptions options)
        {
            options.UseManager <EasyQueryManagerSql>();
            options.DefaultModelId   = "nwind";
            options.BuildQueryOnSync = true;
            options.SaveQueryOnSync  = false;

            options.UseDbContext(ApplicationDbContext.Create());

            // If you want to load model directly from DB metadata
            // remove (or comment) options.UseDbContext(...) call and uncomment the next 3 lines of code
            //options.ConnectionString =
            //    ConfigurationManager.ConnectionStrings["DefaultConnection"]?.ToString();
            //options.UseDbConnection<SqlConnection>();
            //options.UseDbConnectionModelLoader();

            var path = System.Web.Hosting.HostingEnvironment.MapPath("~/App_Data");

            options.UseQueryStore((_) => new FileQueryStore(path));
        }
コード例 #9
0
        protected override void ConfigureEasyQueryOptions(EasyQueryOptions options)
        {
            //use EasyQuery manager that generates SQL queries
            options.UseManager<EasyQueryManagerSql>();

            //options.DefaultModelId = "adhoc-reporting";

            options.StoreModelInCache = true;
            //it is required to register caching service, when StoreInCache is turned on
            options.UseCaching((_) => new EqSessionCachingService());

            //allow save query on sync for users with eq-manager role
            options.SaveQueryOnSync = User.IsInRole("eq-manager");
            options.SaveNewQuery = true;

            var dbContext = ApplicationDbContext.Create();
            options.UseDbContext(dbContext, config => { 

                // Ignore identity tables
                config.AddFilter((entityMap) => {

                    var entType = entityMap.Type;
                    return !(entType.IsInheritedFromGeneric(typeof(IdentityUser<,,,>))
                            || entType.IsInheritedFromGeneric(typeof(IdentityUserClaim<>))
                            || entType.IsInheritedFromGeneric(typeof(IdentityUserRole<>))
                            || entType.IsInheritedFromGeneric(typeof(IdentityUserLogin<>))
                            || entType.IsInheritedFromGeneric(typeof(IdentityRole<,>)));
                });

                // Ignore reports table
                config.AddFilter((entityMap) => {

                    var entType = entityMap.Type;
                    return entType != typeof(Report);
                });
            });

            options.UseQueryStore((_) => new ReportStore(dbContext, User));
            options.UsePaging(30);
        }
コード例 #10
0
        protected override void ConfigureEasyQueryOptions(EasyQueryOptions options)
        {
            options.UseManager <EasyQueryManagerSql>();
            options.DefaultModelId   = "nwind";
            options.BuildQueryOnSync = true;

            options.UseDbContext(ApplicationDbContext.Create());

            // Uncomment the following 3 lines if you want to load model directly from the DB's meta-data
            // (it's better to remove UseDbContext(..) call abouve in this case)
            //options.ConnectionString = "Your connection string";
            //options.UseDbConnection<SqlConnection>();
            //options.UseDbConnectionModelLoader();

            var path = System.Web.Hosting.HostingEnvironment.MapPath("~/App_Data");

            options.UseQueryStore((_) => new FileQueryStore(path));

            options.AddPreFetchTuner(manager => {
                //any code you would like to execute before the data is retrieved from the DB
            });
        }
コード例 #11
0
 public CustomEasyQueryManagerSql(IServiceProvider services, EasyQueryOptions options)
     : base(services, options)
 {
     //ModelLoader = new FileModelLoader("AppData");
 }
コード例 #12
0
ファイル: EqManager.cs プロジェクト: PBWim/EQ
 public EqManager(IServiceProvider services, EasyQueryOptions options)
     : base(services, options)
 {
 }