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