public void AssociationToFilteredEntityFunc([IncludeDataSources(false, TestProvName.AllSQLite)] string context)
        {
            var testData = GenerateTestData();

            Expression <Func <ISoftDelete, MyDataContext, bool> > softDeleteCheck = (e, dc) => !dc.IsSoftDeleteFilterEnabled || !e.IsDeleted;
            var builder = new MappingSchema().GetFluentMappingBuilder();

            builder.Entity <MasterClass>().HasQueryFilter <MyDataContext>((q, dc) => q.Where(e => softDeleteCheck.Compile()(e, dc)));
            builder.Entity <DetailClass>().HasQueryFilter <MyDataContext>((q, dc) => q.Where(e => softDeleteCheck.Compile()(e, dc)));

            var ms = builder.MappingSchema;

            using (new AllowMultipleQuery())
                using (var db = new MyDataContext(context, ms))
                    using (db.CreateLocalTable(testData.Item1))
                        using (db.CreateLocalTable(testData.Item2))
                            using (db.CreateLocalTable(testData.Item3))
                            {
                                var query = from m in db.GetTable <MasterClass>().IgnoreFilters()
                                            from d in m.Details
                                            select d;

                                CheckFiltersForQuery(db, query);
                            }
        }
Beispiel #2
0
        public void EntityFilterTestsCache([IncludeDataSources(false, TestProvName.AllSQLite)] string context, [Values(1, 2, 3)] int iteration, [Values] bool filtered)
        {
            var testData = GenerateTestData();

            using (var db = new MyDataContext(context, _filterMappingSchema))
                using (db.CreateLocalTable(testData.Item1))
                {
                    var currentMissCount = Query <MasterClass> .CacheMissCount;

                    var query = from m in db.GetTable <MasterClass>()
                                select m;

                    ((DcParams)db.Params).IsSoftDeleteFilterEnabled = filtered;

                    var result = query.ToList();

                    if (filtered)
                    {
                        result.Count.Should().BeLessThan(testData.Item1.Length);
                    }
                    else
                    {
                        result.Count.Should().Be(testData.Item1.Length);
                    }

                    if (iteration > 1)
                    {
                        Query <MasterClass> .CacheMissCount.Should().Be(currentMissCount);
                    }
                }
        }
Beispiel #3
0
        public void LicenseTest1()
        {
            var access  = new MyDataContext("C:/Northwind.mdb", typeof(ALinq.Access.AccessDbProvider));
            var q       = access.GetTable <Customer>().ToList();
            var sqlLite = new MyDataContext("C:/Northwind.db3", typeof(ALinq.SQLite.SQLiteProvider));

            q = sqlLite.GetTable <Customer>().ToList();
            var conn = MySqlNorthwind.CreateConnection("root", "test", "Northwind", NorthwindDatabase.DB_HOST, 3306).ConnectionString;

            //var mysql = new MyDataContext(conn, typeof(ALinq.MySQL.MySqlProvider));
            //q = mysql.GetTable<Customer>().ToList();

            conn = OracleNorthwind.CreateConnection("Northwind", "test", "vpc1").ConnectionString;
            var oracle = new MyDataContext(conn, typeof(ALinq.Oracle.OracleProvider));

            q = oracle.GetTable <Customer>().ToList();

            conn = OdpOracleNorthwind.CreateConnection("Northwind", "test", "vpc1").ConnectionString;
            var odpOracle = new MyDataContext(conn, typeof(ALinq.Oracle.Odp.OracleProvider));

            q = oracle.GetTable <Customer>().ToList();

            conn = "User=SYSDBA;Password=masterkey;Database=Northwind;DataSource=vpc1;ServerType=0";
            var firebird = new MyDataContext(conn, typeof(ALinq.Firebird.FirebirdProvider));

            q = firebird.GetTable <Customer>().ToList();

            //conn = "DataBase=SAMPLE;USER ID=db2admin;Password=test;Server=VPC1";
            //var db2 = new MyDataContext(conn, typeof(ALinq.DB2.DB2Provider));
            //q = db2.GetTable<Customer>().ToList();

            //conn = "HOST=VPC1;User ID=postgres;PASSWORD=test;DATABASE=northwind";
            //var pgsql = new MyDataContext(conn, typeof(ALinq.PostgreSQL.PgsqlProvider));
            //pgsql.Connection.Open();
            //q = pgsql.GetTable<Customer>().ToList();
        }
Beispiel #4
0
        public void EntityFilterTests([IncludeDataSources(false, TestProvName.AllSQLite)] string context)
        {
            var testData = GenerateTestData();

            var builder = new MappingSchema().GetFluentMappingBuilder();

            builder.Entity <MasterClass>().HasQueryFilter <MyDataContext>((q, dc) => q.Where(e => !dc.IsSoftDeleteFilterEnabled || !e.IsDeleted));
            builder.Entity <DetailClass>().HasQueryFilter <MyDataContext>((q, dc) => q.Where(e => !dc.IsSoftDeleteFilterEnabled || !e.IsDeleted));

            var ms = builder.MappingSchema;

            using (var db = new MyDataContext(context, ms))
                using (db.CreateLocalTable(testData.Item1))
                    using (db.CreateLocalTable(testData.Item2))
                        using (db.CreateLocalTable(testData.Item3))
                        {
                            var query = from m in db.GetTable <MasterClass>()
                                        select m;

                            CheckFiltersForQuery(db, query);
                        }
        }
Beispiel #5
0
        public void AssociationToFilteredEntityMethod([IncludeDataSources(false, TestProvName.AllSQLite)] string context)
        {
            var testData = GenerateTestData();

            var builder = new MappingSchema().GetFluentMappingBuilder();

            builder.Entity <MasterClass>().HasQueryFilter <MyDataContext>(FilterDeletedCondition);
            builder.Entity <DetailClass>().HasQueryFilter <MyDataContext>(FilterDeletedCondition);

            var ms = builder.MappingSchema;

            using (var db = new MyDataContext(context, ms))
                using (db.CreateLocalTable(testData.Item1))
                    using (db.CreateLocalTable(testData.Item2))
                        using (db.CreateLocalTable(testData.Item3))
                        {
                            var query = from m in db.GetTable <MasterClass>().IgnoreFilters()
                                        from d in m.Details !
                                        select d;

                            CheckFiltersForQuery(db, query);
                        }
        }