当前位置: 首页>>代码示例>>C#>>正文


C# InMemoryAdapter.ConfigureJoin方法代码示例

本文整理汇总了C#中InMemoryAdapter.ConfigureJoin方法的典型用法代码示例。如果您正苦于以下问题:C# InMemoryAdapter.ConfigureJoin方法的具体用法?C# InMemoryAdapter.ConfigureJoin怎么用?C# InMemoryAdapter.ConfigureJoin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在InMemoryAdapter的用法示例。


在下文中一共展示了InMemoryAdapter.ConfigureJoin方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: FindAllWhenUsingAnyOldPropertyNameShouldWork

        public void FindAllWhenUsingAnyOldPropertyNameShouldWork()
        {
            var adapter = new InMemoryAdapter();
            adapter.ConfigureJoin("Users", "Id", "User", "Categories", "UserId", "Categories");
            Database.UseMockAdapter(adapter);
            var db = Database.Open();

            db.Users.Insert(Id: 1, UserName: "Marcus");
            db.Users.Insert(Id: 2, UserName: "Per");
            db.Categories.Insert(Id: 1, UserId: 1, CategoryName: "Category 1");
            db.Categories.Insert(Id: 2, UserId: 2, CategoryName: "Category 2");

            var categories = db.Users.FindAll(db.User.Categories.CategoryName == "Category 1").ToList();
            Assert.NotNull(categories);
            Assert.AreEqual(1, categories.Count);
        }
开发者ID:da9l,项目名称:Simple.Data,代码行数:16,代码来源:InMemoryTests.cs

示例2: TestJoinWithAlias

        public void TestJoinWithAlias()
        {
            var adapter = new InMemoryAdapter();
            adapter.ConfigureJoin("Customer", "ID", "Customer", "Orders", "CustomerID", "Orders");
            Database.UseMockAdapter(adapter);
            var db = Database.Open();
            db.Customer.Insert(ID: 1, Name: "NASA");
            db.Customer.Insert(ID: 2, Name: "ACME");
            db.Orders.Insert(ID: 1, Name: "Order1", CustomerID: 1);
            db.Orders.Insert(ID: 2, Name: "Order2", CustomerID: 2);
            db.Orders.Insert(ID: 3, Name: "Order3", CustomerID: 2);

            IEnumerable<dynamic> orders = db.Orders.Query()
                .Where(db.Orders.Customer.Name == "ACME")
                .Select(db.Orders.Name.As("OrderName"),
                        db.Orders.Customer.Name.As("CustomerName"))
                .ToList();
            Assert.IsNotNull(orders);
            Assert.AreEqual(2, orders.Count());
            Assert.AreEqual(2, orders.Count(x => x.CustomerName == "ACME"));
        }
开发者ID:da9l,项目名称:Simple.Data,代码行数:21,代码来源:InMemoryTests.cs

示例3: TestJoin

        public void TestJoin()
        {
            var adapter = new InMemoryAdapter();
            adapter.ConfigureJoin("Customer", "ID", "Customer", "Order", "CustomerID", "Orders");
            Database.UseMockAdapter(adapter);
            var db = Database.Open();
            db.Customer.Insert(ID: 1, Name: "NASA");
            db.Customer.Insert(ID: 2, Name: "ACME");
            db.Order.Insert(ID: 1, CustomerID: 1, Date: new DateTime(1997, 1, 12));
            db.Order.Insert(ID: 2, CustomerID: 2, Date: new DateTime(2001, 1, 1));

            var customers = db.Customer.FindAll(db.Customer.Orders.Date < new DateTime(1999, 12, 31)).ToList();
            Assert.IsNotNull(customers);
            Assert.AreEqual(1, customers.Count);
        }
开发者ID:da9l,项目名称:Simple.Data,代码行数:15,代码来源:InMemoryTests.cs


注:本文中的InMemoryAdapter.ConfigureJoin方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。