本文整理汇总了C#中ISession.GetAll方法的典型用法代码示例。如果您正苦于以下问题:C# ISession.GetAll方法的具体用法?C# ISession.GetAll怎么用?C# ISession.GetAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ISession
的用法示例。
在下文中一共展示了ISession.GetAll方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Session_Delete_Employee
public void Session_Delete_Employee(ISession session)
{
session.WithRollback(s =>
{
var count = session.GetAll<Employee>().Count();
var sergio = session.Insert(new Employee
{
FirstName = "Sérgio",
LastName = "Ferreira"
});
session.Delete(sergio);
Assert.AreEqual(count, session.GetAll<Employee>().Count());
}
);
}
示例2: MoreComplexQuery
public void MoreComplexQuery(ISession session)
{
var employees = session
.GetAll<Employee>()
.Where(m => m.EmployeeId > 0)
.And(m => m.EmployeeId < 10)
.OrderBy(m => m.City)
.Descending();
Assert.AreEqual(9, employees.Count());
}
示例3: MoreComplexQuery2
public void MoreComplexQuery2(ISession session)
{
var employees = session
.GetAll<Employee>()
.Where(e => e.LastName).Like("r")
.Or(e => e.LastName).Like("a")
.OrderBy(m => m.City)
.Descending();
Assert.AreEqual(8, employees.Count());
}
示例4: QueryWith_OrCondition
public void QueryWith_OrCondition(ISession session)
{
var employees = session
.GetAll<Employee>()
.Where(m => m.EmployeeId == 1)
.Or(m => m.EmployeeId == 4)
.Or(m => m.EmployeeId == 2)
.Or(m => m.EmployeeId == 5)
.And(m => m.EmployeeId > 3);
Assert.AreEqual(2, employees.Count());
}
示例5: Session_GetAll_withWhereCond_AndMoreConditions
public void Session_GetAll_withWhereCond_AndMoreConditions(ISession session)
{
var employees = session
.GetAll<Employee>()
.Where("FirstName = '{0}'", "Nancy")
.And("LastName = '{0}'", "Davolio");
Assert.AreEqual(1, employees.Count());
}
示例6: Session_GetById_With_Setted_Territories
public void Session_GetById_With_Setted_Territories(ISession session)
{
var employee = session.GetById(new Employee { EmployeeId = 1 });
// The territories property should be affected!
employee.Territories = session.GetAll<EmployeeTerritories>();
// Should contain all the EmployeeTerritories instances.
var territories = employee.Territories;
Assert.That(employee.Territories.Count(), Is.EqualTo(49));
}
示例7: Session_GetAll_withInConditionExpression_Complex
public void Session_GetAll_withInConditionExpression_Complex(ISession session)
{
var employees = session
.GetAll<Employee>()
.Where(m => m.EmployeeId).In(new[] { 1, 2, 3, 4, 5, 6, 7 })
.And(m => m.EmployeeId >= 2);
Assert.AreEqual(6, employees.Count());
}
示例8: Session_GetAll_withWhereCond
public void Session_GetAll_withWhereCond(ISession session)
{
var employees = session
.GetAll<Employee>()
.Where("EmployeeId = {0}", 1);
Assert.AreEqual(1, employees.Count());
}
示例9: Session_GetAll_Between
public void Session_GetAll_Between(ISession session)
{
var employees = session
.GetAll<Employee>()
.Where(m => m.EmployeeId)
.Between(1, 5);
Assert.AreEqual(5, employees.Count());
}
示例10: Session_GetAll_withInConditionExpression
public void Session_GetAll_withInConditionExpression(ISession session)
{
var employees = session
.GetAll<Employee>()
.Where(m => m.EmployeeId)
.In(new[] { 1, 2, 3 });
Assert.AreEqual(3, employees.Count());
}
示例11: Session_WhereCondition_ShouldBeKept_ByResult
public void Session_WhereCondition_ShouldBeKept_ByResult(ISession session)
{
var query1 = session.GetAll<Employee>()
.Where(m => m.EmployeeId > 4);
var query2 = session.GetAll<Employee>()
.Where(m => m.EmployeeId == 2);
var query3 = session.GetAll<Employee>()
.Where(m => m.EmployeeId == 2)
.Or(m => m.EmployeeId == 3);
Assert.AreEqual(5, query1.Count());
Assert.AreEqual(1, query2.Count());
Assert.AreEqual(2, query3.Count());
Assert.AreEqual(5, query1.Count());
Assert.AreEqual(1, query2.Count());
Assert.AreEqual(2, query3.Count());
}
示例12: Session_GetAll_Employees_From_Orders
public void Session_GetAll_Employees_From_Orders(ISession session)
{
var employees = session.GetAll<Employee>()
.Where(e => e.ReportsTo).In(
session.GetAll<Orders>()
);
Assert.AreEqual(9, employees.Count());
}
示例13: Session_GetAll_OrderedByCity_Descending
public void Session_GetAll_OrderedByCity_Descending(ISession session)
{
var employee2 = session
.GetAll<Employee>()
.OrderBy(e => e.City)
.Descending()
.First();
EntitiesAsserts.Assert_Employee_2(employee2);
var employee3 = session
.GetAll<Employee>()
.OrderBy(e => e.City)
.First();
EntitiesAsserts.Assert_Employee_3(employee3);
}
示例14: Session_GetEmployeeList_ReportsToFilter
public void Session_GetEmployeeList_ReportsToFilter(ISession session)
{
/*
* Select * from Employees Where ReportsTo in
* (Select EmployeeId From Employees Where FirstName = 'Andrew')
*/
var employees1 = session
.GetAll<Employee>().Where(e => e.ReportsTo.FirstName == "Andrew");
Assert.AreEqual(5, employees1.Count());
EntitiesAsserts.Assert_Employee_1(employees1.First());
/*
* Select * From Employees Where ReportsTo in
* (Select EmployeeId From Employees Where EmployeeId = 1)
*/
var employees2 = session
.GetAll<Employee>().Where(e => e.ReportsTo.EmployeeId == 1);
EntitiesAsserts.Assert_Employee_2(employees2.First());
}
示例15: Session_GetAll_LikeCondition_Left
public void Session_GetAll_LikeCondition_Left(ISession session)
{
var employees = session
.GetAll<Employee>()
.Where(e => e.LastName).Like("r", WildCard.Left);
Assert.AreEqual(1, employees.Count());
}