Beispiel #1
0
 public DBContext()
     : base("name=DBContext")
 {
     QueryFilterManager.Filter <Kitaplar>(c => c.Where(x => x.isActive == true));
     QueryFilterManager.Filter <KullanimDetay>(c => c.Where(x => x.isActive == true));
     QueryFilterManager.Filter <Raflar>(c => c.Where(x => x.isActive == true));
     QueryFilterManager.Filter <Yorumlar>(c => c.Where(x => x.isActive == true));
     QueryFilterManager.InitilizeGlobalFilter(this);
 }
        private void Initialize()
        {
            Configuration.LazyLoadingEnabled   = false;
            Configuration.ProxyCreationEnabled = false;

            if (isAnyFilterInitilized)
            {
                QueryFilterManager.InitilizeGlobalFilter(this);
            }
        }
        public void WithGlobalManagerFilter_ManyFilter_Enabled()
        {
            using (var ctx = new TestContext())
            {
                QueryFilterHelper.CreateGlobalManagerFilter(false, enableFilter1: true, enableFilter2: true, enableFilter3: true, enableFilter4: true);
                QueryFilterManager.InitilizeGlobalFilter(ctx);

                Assert.AreEqual(45, ctx.Inheritance_Interface_Entities.AsNoFilter().Sum(x => x.ColumnInt));

                QueryFilterHelper.ClearGlobalManagerFilter();
            }
        }
        public void WithGlobalManagerFilter_ManyFilter_Include()
        {
            using (var ctx = new TestContext())
            {
                QueryFilterHelper.CreateGlobalManagerFilter(true, enableFilter1: false, enableFilter2: false, enableFilter3: false, enableFilter4: false, includeInterface: true, includeBaseClass: true, includeBaseInterface: true);
                QueryFilterManager.InitilizeGlobalFilter(ctx);

                Assert.AreEqual(36, ctx.Inheritance_Interface_Entities.Sum(x => x.ColumnInt));

                QueryFilterHelper.ClearGlobalManagerFilter();
            }
        }
Beispiel #5
0
        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        {
            base.OnConfiguring(optionsBuilder);

            optionsBuilder.UseLazyLoadingProxies(false);
            if (isAnyFilterInitilized)
            {
                QueryFilterManager.InitilizeGlobalFilter(this);
            }

            optionsBuilder.UseLoggerFactory(ImsLogging.LoggerFactory);
        }
        public ApplicationDbContext(AppTenant tenant)
        {
            if (tenant != null)
            {
                this.tenant = tenant;
                this.Seed(this.tenant);
                var tenantId = this.tenant.AppTenantId;

                QueryFilterManager.Filter <Page>(q => q.Where(x => x.AppTenantId == tenantId));

                QueryFilterManager.InitilizeGlobalFilter(this);
            }
        }
        public void WithGlobalManagerFilter_SingleFilter_Include()
        {
            TestContext.DeleteAll(x => x.Inheritance_Interface_Entities);
            TestContext.Insert(x => x.Inheritance_Interface_Entities, 10);

            using (var ctx = new TestContext())
            {
                QueryFilterHelper.CreateGlobalManagerFilter(true, enableFilter1: false, includeClass: true);
                QueryFilterManager.InitilizeGlobalFilter(ctx);

                Assert.AreEqual(44, ctx.Inheritance_Interface_Entities.Sum(x => x.ColumnInt));

                QueryFilterHelper.ClearGlobalManagerFilter();
            }
        }
Beispiel #8
0
        public void WithGlobalManagerFilter_ManyFilter_Exclude()
        {
            TestContext.DeleteAll(x => x.Inheritance_Interface_Entities);
            TestContext.Insert(x => x.Inheritance_Interface_Entities, 10);

            using (var ctx = new TestContext())
            {
                QueryFilterHelper.CreateGlobalManagerFilter(false, enableFilter1: true, enableFilter2: true, enableFilter3: true, enableFilter4: true, excludeInterface: true, excludeBaseClass: true, excludeBaseInterface: true);
                QueryFilterManager.InitilizeGlobalFilter(ctx);

                Assert.AreEqual(44, ctx.SetFiltered <Inheritance_Interface_Entity>().Sum(x => x.ColumnInt));

                QueryFilterHelper.ClearGlobalManagerFilter();
            }
        }
Beispiel #9
0
        public void WithGlobalManagerFilter_ManyFilter_Disabled()
        {
            TestContext.DeleteAll(x => x.Inheritance_Interface_Entities);
            TestContext.Insert(x => x.Inheritance_Interface_Entities, 10);

            using (var ctx = new TestContext())
            {
                QueryFilterHelper.CreateGlobalManagerFilter(true, enableFilter1: false, enableFilter2: false, enableFilter3: false, enableFilter4: false);
                QueryFilterManager.InitilizeGlobalFilter(ctx);

                Assert.AreEqual(35, ctx.Inheritance_Interface_Entities.Filter(
                                    QueryFilterHelper.Filter.Filter1,
                                    QueryFilterHelper.Filter.Filter2,
                                    QueryFilterHelper.Filter.Filter3,
                                    QueryFilterHelper.Filter.Filter4).Sum(x => x.ColumnInt));

                QueryFilterHelper.ClearGlobalManagerFilter();
            }
        }
        private static void RunQueriesWithGlobalFilter()
        {
            Console.WriteLine("\n ** Test 2: Queries with global filter");
            QueryFilterManager.Filter <Contact>(q => q.Where(x => x.IsDeleted == true));

            using (var dbContext = new TestDbContext())
            {
                Console.WriteLine("\t First time query execution");
                QueryFilterManager.InitilizeGlobalFilter(dbContext);
                dbContext.Contacts.ToList();
            }

            using (var dbContext = new TestDbContext())
            {
                Console.WriteLine("\t Second time query execution");
                QueryFilterManager.InitilizeGlobalFilter(dbContext);
                dbContext.Contacts.ToList();
            }
        }
Beispiel #11
0
        public static void Run_Filter()
        {
            // CREATE global filter
            QueryFilterManager.Filter <Flight>(x => x.Where(c => c.Departure == "Rome"));

            var ctx = new DA.WWWingsContext();

            ctx.Log();


            // TIP: Add this line in EntitiesContext constructor instead
            QueryFilterManager.InitilizeGlobalFilter(ctx);

            // SELECT * FROM Customer WHERE IsActive = true
            var customer = ctx.FlightSet.ToList();

            foreach (var f in customer)
            {
                Console.WriteLine(f);
            }
        }
Beispiel #12
0
 public MiruDbContext(IMiruApp app) : base(app.Get <DbContextOptions>())
 {
     QueryFilterManager.InitilizeGlobalFilter(this);
 }
Beispiel #13
0
 // Your context has been configured to use a 'BookingContext' connection string from your application's
 // configuration file (App.config or Web.config). By default, this connection string targets the
 // 'BookingSystem.API.Models.BookingContext' database on your LocalDb instance.
 //
 // If you wish to target a different database and/or database provider, modify the 'BookingContext'
 // connection string in the application configuration file.
 public BookingContext()
     : base("name=BookingContext")
 {
     QueryFilterManager.InitilizeGlobalFilter(this);
 }
Beispiel #14
0
 public RPCSContext(DbContextOptions <RPCSContext> options) : base(options)
 {
     QueryFilterManager.Filter <BaseModel>("IsVersion", m => m.Where(x => !x.IsVersion), true);
     QueryFilterManager.Filter <BaseModel>("IsDeleted", m => m.Where(x => !x.IsDeleted), true);
     QueryFilterManager.InitilizeGlobalFilter(this);
 }