本文整理汇总了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);
}
示例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"));
}
示例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);
}