本文整理汇总了C#中ISession.GetById方法的典型用法代码示例。如果您正苦于以下问题:C# ISession.GetById方法的具体用法?C# ISession.GetById怎么用?C# ISession.GetById使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ISession
的用法示例。
在下文中一共展示了ISession.GetById方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Session_Update_Employee
public void Session_Update_Employee(ISession session)
{
session.WithRollback(s =>
{
var sergio = session.Insert(new Employee
{
FirstName = "Sérgio",
LastName = "Ferreira"
});
sergio.FirstName = "Alien";
session.Update(sergio);
var alien = session.GetById(sergio);
Assert.That(alien, Is.Not.Null);
Assert.AreEqual("Alien", alien.FirstName);
}
);
}
示例2: Session_Reuse_Returned_Entity
public void Session_Reuse_Returned_Entity(ISession session)
{
var employee = session.GetById(new Employee { EmployeeId = 1 });
var reportsTo = session.GetById(employee.ReportsTo);
Assert.That(reportsTo, Is.Not.Null);
EntitiesAsserts.Assert_Employee_2(reportsTo);
}
示例3: 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));
}
示例4: Session_GetById_Territories
public void Session_GetById_Territories(ISession session)
{
var employee = session.GetById(
new Employee { EmployeeId = 1 });
Assert.That(employee.Territories.Count(), Is.EqualTo(2));
}
示例5: Session_GetById_ReportsTo
public void Session_GetById_ReportsTo(ISession session)
{
var employee = session.GetById(
new Employee { EmployeeId = 1 });
EntitiesAsserts.Assert_Employee_2(employee.ReportsTo);
EntitiesAsserts.Assert_Employee_1(employee.ReportsTo.ReportsTo);
EntitiesAsserts.Assert_Employee_2(employee.ReportsTo.ReportsTo.ReportsTo);
EntitiesAsserts.Assert_Employee_1(employee);
}
示例6: Session_GetAll_In_using_collection_SameNames
public void Session_GetAll_In_using_collection_SameNames(ISession session)
{
var employee = session.GetById(new Employee { EmployeeId = 5 });
/*
Select * From Employees Where EmployeeId In (
Select EmployeeId From Employees Where ReportsTo = @p1
)
*/
var employees = session.GetAll<Employee>()
.Where(m => m.EmployeeId)
.In(
session.GetAll<Employee>().Where(m => m.ReportsTo.EmployeeId == employee.EmployeeId)
);
Assert.AreEqual(3, employees.Count());
}