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


C# ISession.GetById方法代码示例

本文整理汇总了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);
                }
            );
        }
开发者ID:stalinvr007,项目名称:VoDB,代码行数:21,代码来源:Session_Tests.cs

示例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);
        }
开发者ID:stalinvr007,项目名称:VoDB,代码行数:9,代码来源:Session_Tests.cs

示例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));
        }
开发者ID:stalinvr007,项目名称:VoDB,代码行数:12,代码来源:Session_Tests.cs

示例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));
        }
开发者ID:stalinvr007,项目名称:VoDB,代码行数:7,代码来源:Session_Tests.cs

示例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);
        }
开发者ID:stalinvr007,项目名称:VoDB,代码行数:10,代码来源:Session_Tests.cs

示例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());
        }
开发者ID:stalinvr007,项目名称:VoDB,代码行数:18,代码来源:Session_Tests.cs


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