public void TableNames()
        {
            using (var ctx = GetContext())
            {
                var sw = new Stopwatch();
                sw.Start();
                var x = ctx.Blogs.FirstOrDefault();
                sw.Stop();
                Console.WriteLine("Initializing model took: {0}ms", sw.Elapsed.TotalMilliseconds);

                sw.Restart();
                var dbmapping = EfMap.Get(ctx);
                sw.Start();

                Console.WriteLine("Mapping took: {0}ms", sw.Elapsed.TotalMilliseconds);

                var tableMappings = dbmapping.Tables;

                foreach (var tableMapping in tableMappings)
                {
                    Console.WriteLine("{0}: {1}", tableMapping.TypeFullName, tableMapping.TableName);
                }

                Assert.AreEqual(2, tableMappings.Length);

                AssertTableName <Blogs>(tableMappings, "Blogs");
                AssertTableName <Posts>(tableMappings, "Posts");
            }
        }
        public void ColumnNames_TPH_ContractKomb2()
        {
            using (var ctx = new TestContext())
            {
                var tableMapping = EfMap.Get <ContractKomb2>(ctx);

                var columns = tableMapping.Columns;
                Assert.AreEqual(25, columns.Length);
            }
        }
        public void ColumnNames_Posts()
        {
            using (var ctx = GetContext())
            {
                var tableMapping = EfMap.Get <Posts>(ctx);
                var columns      = tableMapping.Columns;
                Assert.AreEqual(4, columns.Length);

                AssertColumnName(columns, "PostId", "PostId");
                AssertColumnName(columns, "Title", "Title");
                AssertColumnName(columns, "Content", "Content");
                AssertColumnName(columns, "BlogId", "BlogId");
            }
        }
        public void ColumnNames_Blogs()
        {
            using (var ctx = GetContext())
            {
                var tableMapping = EfMap.Get <Blogs>(ctx);

                var columns = tableMapping.Columns;
                Assert.AreEqual(3, columns.Length);

                AssertColumnName(columns, "BlogId", "BlogId");
                AssertColumnName(columns, "Name", "Name");
                AssertColumnName(columns, "Url", "Url");
            }
        }
        public void ColumnNames_TPH_BaseClass()
        {
            using (var ctx = GetContext())
            {
                Console.WriteLine("EmployeeTPH");
                var tableMapping = EfMap.Get <EmployeeTPH>(ctx);
                var columns      = tableMapping.Columns;
                Assert.AreEqual(4, columns.Length);

                AssertColumnName(columns, "Id", "Id");
                AssertColumnName(columns, "Name", "Name");
                AssertColumnName(columns, "JobTitle", "Title");
                AssertColumnName(columns, "__employeeType", "__employeeType");
            }
        }
        public void ColumnNames_Simple()
        {
            using (var ctx = new TestContext())
            {
                var tableMapping = EfMap.Get <Page>(ctx);

                var columns = tableMapping.Columns;
                Assert.AreEqual(6, columns.Length);

                AssertColumnName(columns, "PageId", "PageId");
                AssertColumnName(columns, "Title", "Title");
                AssertColumnName(columns, "Content", "Content");
                AssertColumnName(columns, "ParentId", "ParentId");
                AssertColumnName(columns, "CreatedAt", "CreatedAt");
                AssertColumnName(columns, "ModifiedAt", "ModifiedAt");
            }
        }
        public void ColumnNames_TPH_DerivedType_NotFirst()
        {
            using (var ctx = GetContext())
            {
                Console.WriteLine("ManagerTMP");
                var tableMapping = EfMap.Get <ManagerTPH>(ctx);
                var columns      = tableMapping.Columns;
                Assert.AreEqual(6, columns.Length);

                AssertColumnName(columns, "Id", "Id");
                AssertColumnName(columns, "Name", "Name");
                AssertColumnName(columns, "JobTitle", "Title");
                AssertColumnName(columns, "Rank", "Rank");
                AssertColumnName(columns, "RefId1", "RefId");
                AssertColumnName(columns, "__employeeType", "__employeeType");
            }
        }
        public void Issue1344()
        {
            using (var ctx = new AccrualContext())
            {
                var tableMapping = EfMap.Get <Post>(ctx);
                var columns      = tableMapping.Columns;

                Assert.AreEqual(23, columns.Length);

                foreach (var columnMapping in columns)
                {
                    Console.WriteLine("{0}\t{1}", columnMapping.ColumnName, columnMapping.PropertyName);
                }

                AssertColumnName(tableMapping.Columns, "GCRecord", "GcRecord");
            }
        }
        public void TableNames()
        {
            using (var ctx = GetContext())
            {
                InitializeContext();

                var sw = new Stopwatch();
                sw.Restart();
                var dbmapping = EfMap.Get(ctx);
                sw.Start();

                Console.WriteLine("Mapping took: {0}ms", sw.Elapsed.TotalMilliseconds);

                var tableMappings = dbmapping.Tables;

                foreach (var tableMapping in tableMappings)
                {
                    Console.WriteLine("{0}: {1}", tableMapping.TypeFullName, tableMapping.TableName);
                }

                Assert.AreEqual(15, tableMappings.Length);

                AssertTableName <Page>(tableMappings, "Pages");
                AssertTableName <PageTranslations>(tableMappings, "PageTranslations");

                AssertTableName <TestUser>(tableMappings, "Users");

                AssertTableName <MeteringPoint>(tableMappings, "MeteringPoints");

                AssertTableName <EmployeeTPH>(tableMappings, "EmployeeTPHs");
                AssertTableName <AWorkerTPH>(tableMappings, "EmployeeTPHs");
                AssertTableName <ManagerTPH>(tableMappings, "EmployeeTPHs");

                AssertTableName <ContractBase>(tableMappings, "Contracts");
                AssertTableName <Contract>(tableMappings, "Contracts");
                AssertTableName <ContractFixed>(tableMappings, "Contracts");
                AssertTableName <ContractStock>(tableMappings, "Contracts");
                AssertTableName <ContractKomb1>(tableMappings, "Contracts");
                AssertTableName <ContractKomb2>(tableMappings, "Contracts");

                AssertTableName <WorkerTPT>(tableMappings, "WorkerTPTs");
                AssertTableName <ManagerTPT>(tableMappings, "ManagerTPTs");
            }
        }
        public void ColumnNames_ComplexType()
        {
            using (var ctx = new TestContext())
            {
                var tableMapping = EfMap.Get <TestUser>(ctx);

                var columns = tableMapping.Columns;
                Assert.AreEqual(9, columns.Length);

                AssertColumnName(columns, "Id", "Id");
                AssertColumnName(columns, "Name", "FirstName");
                AssertColumnName(columns, "LastName", "LastName");
                AssertColumnName(columns, "Contact_PhoneNumber", "Contact.PhoneNumber");
                AssertColumnName(columns, "Contact_Address_Country", "Contact.Address.Country");
                AssertColumnName(columns, "Contact_Address_County", "Contact.Address.County");
                AssertColumnName(columns, "Contact_Address_City", "Contact.Address.City");
                AssertColumnName(columns, "Contact_Address_PostalCode", "Contact.Address.PostalCode");
                AssertColumnName(columns, "Contact_Address_StreetAddress", "Contact.Address.StreetAddress");
            }
        }
        public void ColumnNames_TPT()
        {
            using (var ctx = GetContext())
            {
                var tableMapping = EfMap.Get <WorkerTPT>(ctx);
                var columns      = tableMapping.Columns;

                Cols(columns)
                .Count(4)
                .Col("Id")
                .IsPk().Prop("Id").IsRefObj(false)
                .And
                .Col("Name")
                .IsPk(false).Prop("Name").IsRefObj(false)
                .And
                .Col("JobTitle")
                .IsPk(false).Prop("JobTitle").IsRefObj(false)
                .And
                .Col("Boss_Id")
                .IsPk(false).Prop("Boss").IsRefObj(true);

                tableMapping = EfMap.Get <ManagerTPT>(ctx);
                columns      = tableMapping.Columns;

                Cols(columns)
                .Count(4)
                .Col("Id")
                .IsPk().Prop("Id").IsRefObj(false)
                .And
                .Col("Name")
                .IsPk(false).Prop("Name").IsRefObj(false)
                .And
                .Col("JobTitle")
                .IsPk(false).Prop("JobTitle").IsRefObj(false)
                .And
                .Col("Rank")
                .IsPk(false).Prop("Rank").IsRefObj(false);
            }
        }
Exemple #12
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="ctx"></param>
 /// <param name="typeFullName"></param>
 /// <returns></returns>
 public static IEntityMap Db(this DbContext ctx, string typeFullName)
 {
     return(EfMap.Get(ctx)[typeFullName]);
 }
Exemple #13
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="ctx"></param>
 /// <param name="type"></param>
 /// <returns></returns>
 public static IEntityMap Db(this DbContext ctx, Type type)
 {
     return(EfMap.Get(ctx)[type]);
 }
Exemple #14
0
 /// <summary>
 ///
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="ctx"></param>
 /// <returns></returns>
 public static IEntityMap <T> Db <T>(this DbContext ctx)
 {
     return(EfMap.Get <T>(ctx));
 }
Exemple #15
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="ctx"></param>
 /// <returns></returns>
 public static IEntityMap[] Db(this DbContext ctx)
 {
     return(EfMap.Get(ctx).Tables);
 }