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


C# ISession.Search方法代码示例

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


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

示例1: TestDelete

 private static void TestDelete( ISession session )
 {
     Student[] result;
     Console.WriteLine ( "Delete an object..." );
     result = session.Search<Student> ( "StudentId=='200730740404'" );
     session.Delete ( result[0] );
     session.Submit ();
     Console.WriteLine ( "Deleted Successfully..." );
     Console.ReadKey ();
     ReadObjects ( session );
 }
开发者ID:phospher,项目名称:SchoolEndORM,代码行数:11,代码来源:Program.cs

示例2: ReadObjects

 private static void ReadObjects( ISession session )
 {
     Console.WriteLine ( "Get objects from database..." );
     Console.WriteLine ( "--------------------------------" );
     IEnumerable<Student> result = session.Search<Student> ( "1==1" );
     foreach ( Student item in result ) {
         Console.WriteLine ( "{0}--{1}--{2}", item.StudentId, item.Name, item.Gender );
     }
     Console.WriteLine ( "-------------------------------------" );
     Console.WriteLine ( "Got objects successfully..." );
 }
开发者ID:phospher,项目名称:SchoolEndORM,代码行数:11,代码来源:Program.cs

示例3: TestManyToMany

 private static void TestManyToMany( ISession session )
 {
     Course[] result;
     Console.WriteLine ( "Test many-to-many relation..." );
     Console.WriteLine ( "Get an object;" );
     result = session.Search<Course> ( "Id==1" );
     Console.WriteLine ( "{0}--{1}--{2}", result[0].Id, result[0].Name, result[0].Classroom );
     Console.WriteLine ( "Objects refer to the object:" );
     foreach ( Student s in result[0].Students ) {
         Console.WriteLine ( "{0}--{1}--{2}", s.StudentId, s.Name, s.Gender );
     }
 }
开发者ID:phospher,项目名称:SchoolEndORM,代码行数:12,代码来源:Program.cs

示例4: TestManyToOne

 private static void TestManyToOne( ISession session )
 {
     Teacher[] result;
     Console.WriteLine ( "Test many-to-one relation..." );
     Console.WriteLine ( "Get an object:" );
     result = session.Search<Teacher> ( "Id==1" );
     Console.WriteLine ( "{0}--{1}--{2}", result[0].Id, result[0].Name, result[0].Gender );
     Console.WriteLine ( "Object refers to the object:" );
     Console.WriteLine ( "{0}--{1}", result[0].Department.Id, result[0].Department.Name );
 }
开发者ID:phospher,项目名称:SchoolEndORM,代码行数:10,代码来源:Program.cs

示例5: TestUpdate

 private static void TestUpdate( ISession session )
 {
     Student[] result;
     Console.WriteLine ( "Update an object..." );
     result = session.Search<Student> ( "StudentId=='200730740402'" );
     result[0].Name = "Lisa";
     result[0].Gender = "Female";
     session.Update ( result[0] );
     session.Submit ();
     Console.WriteLine ( "Updated Successfully..." );
     Console.ReadKey ();
     ReadObjects ( session );
 }
开发者ID:phospher,项目名称:SchoolEndORM,代码行数:13,代码来源:Program.cs

示例6: TestOneToOne

 private static void TestOneToOne( ISession session )
 {
     ContactMenu[] result;
     Console.WriteLine ( "Test one-to-one relation..." );
     Console.WriteLine ( "Get an object:" );
     result = session.Search<ContactMenu> ( "Email=='[email protected]'" );
     Console.WriteLine ( "{0}--{1}--{2}", result[0].Phone, result[0].Email, result[0].Address );
     Console.WriteLine ( "Object refers to the object:" );
     Console.WriteLine ( "{0}--{1}--{2}", result[0].Student.StudentId, result[0].Student.Name, result[0].Student.Gender );
 }
开发者ID:phospher,项目名称:SchoolEndORM,代码行数:10,代码来源:Program.cs

示例7: TestOneToMany

 private static void TestOneToMany( ISession session )
 {
     Department[] result;
     Console.WriteLine ( "Test one-to-many relation..." );
     Console.WriteLine ( "Get an object:" );
     result = session.Search<Department> ( "Id==1" );
     Console.WriteLine ( "{0}--{1}", result[0].Id, result[0].Name );
     Console.WriteLine ( "Objects refer to the object:" );
     foreach ( Teacher t in result[0].Teachers ) {
         Console.WriteLine ( "{0}--{1}--{2}", t.Id, t.Name, t.Gender );
     }
 }
开发者ID:phospher,项目名称:SchoolEndORM,代码行数:12,代码来源:Program.cs


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