本文整理匯總了C#中SqlBuilder.GetStatement方法的典型用法代碼示例。如果您正苦於以下問題:C# SqlBuilder.GetStatement方法的具體用法?C# SqlBuilder.GetStatement怎麽用?C# SqlBuilder.GetStatement使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類SqlBuilder
的用法示例。
在下文中一共展示了SqlBuilder.GetStatement方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: Init
public void Init()
{
GentleSettings.CacheObjects = false;
CacheManager.Clear();
SqlBuilder sb = new SqlBuilder( StatementType.Delete, typeof(MultiType) );
Broker.Execute( sb.GetStatement( true ) );
}
示例2: TestCRUD
public void TestCRUD()
{
// skip test if GUIDs are not supported by database backend
if( runTest )
{
o1 = new GuidHolder( 42 );
// insert
o1.Persist();
// select
o2 = GuidHolder.Retrieve( o1.Id );
// verify select/insert
Assert.IsNotNull( o2.Id, "The object could not be retrieved from the database!" );
Assert.AreEqual( o1.Id, o2.Id, "The object could not be retrieved from the database!" );
Assert.AreEqual( o1.SomeValue, o2.SomeValue, "The object could not be retrieved from the database!" );
// update
o2.SomeValue = 1234;
o2.Persist();
// verify update
o1 = GuidHolder.Retrieve( o2.Id );
Assert.AreEqual( o2.Id, o1.Id, "The object could not be retrieved from the database!" );
// delete
o2.Remove();
// verify delete by counting the number of rows
SqlBuilder sb = new SqlBuilder( StatementType.Count, typeof(GuidHolder) );
sb.AddConstraint( Operator.Equals, "Id", o1.Id );
SqlResult sr = Broker.Execute( sb.GetStatement( true ) );
Assert.AreEqual( 0, sr.Count, "Object not removed" );
}
}
示例3: GetCount
private int GetCount( SqlBuilder builder )
{
SqlStatement statement = builder.GetStatement();
SqlResult result = statement.Execute();
int count = result.Count;
return count;
}
示例4: Init
public void Init()
{
GentleSettings.CacheObjects = false;
CacheManager.Clear();
// make sure table is empty before we start
SqlBuilder sb = new SqlBuilder( StatementType.Delete, typeof(PropertyHolder) );
Broker.Execute( sb.GetStatement( true ) );
}
示例5: Final
public void Final()
{
if( runTest )
{
SqlBuilder sb = new SqlBuilder( StatementType.Delete, typeof(MemberPicture) );
Broker.Execute( sb.GetStatement( true ) );
}
}
示例6: Final
public void Final()
{
// make sure we have only the default 4 members
SqlBuilder sb = new SqlBuilder( StatementType.Delete, typeof(MemberSD) );
sb.AddConstraint( Operator.GreaterThan, "Id", 4 );
Broker.Execute( sb.GetStatement( true ) );
// remove the list
list.Remove();
}
示例7: CleanUp
public void CleanUp()
{
if( runTests )
{
SqlBuilder sb = new SqlBuilder( StatementType.Delete, typeof(ReservedWords) );
SqlStatement stmt = sb.GetStatement( true );
stmt.Execute();
}
}
示例8: GetRawTableData
private SqlResult GetRawTableData()
{
SqlBuilder sb = new SqlBuilder( StatementType.Select, typeof(PHNullableType) );
SqlStatement stmt = sb.GetStatement( true );
// override generated statement to make sure we execute this without any type association
stmt = new SqlStatement( StatementType.Select, Broker.Provider.GetCommand(), stmt.Sql );
SqlResult sr = stmt.Execute();
return sr;
}
示例9: Init
public void Init()
{
// make sure we have only 4 members
SqlBuilder sb = new SqlBuilder( StatementType.Delete, typeof(Member) );
sb.AddConstraint( Operator.GreaterThan, "Id", 4 );
Broker.Execute( sb.GetStatement( true ) );
// make sure we have only 3 lists
sb = new SqlBuilder( StatementType.Delete, typeof(MailingList) );
sb.AddConstraint( Operator.GreaterThan, "Id", 3 );
Broker.Execute( sb.GetStatement( true ) );
}
示例10: Init
public void Init()
{
// make sure we have only 4 members
SqlBuilder sb = new SqlBuilder( StatementType.Delete, typeof(MemberCC) );
sb.AddConstraint( Operator.GreaterThan, "Id", 4 );
Broker.Execute( sb.GetStatement( true ) );
// make sure we have only 3 lists
sb = new SqlBuilder( StatementType.Delete, typeof(MailingList) );
sb.AddConstraint( Operator.GreaterThan, "Id", 3 );
Broker.Execute( sb.GetStatement( true ) );
// create an empty mailing list
list = new MailingList( "SomeList", "[email protected]" );
list.Persist();
}
示例11: Init
public void Init()
{
// disable query caching
GentleSettings.SkipQueryExecution = false;
// clean any existing entries
SqlBuilder sb = new SqlBuilder( StatementType.Delete, typeof(UserRole) );
Broker.Execute( sb.GetStatement() );
// clean out roles table
sb = new SqlBuilder( StatementType.Delete, typeof(Role) );
Broker.Execute( sb.GetStatement() );
// populate table with known roles
fixedRoles = new Role[Enum.GetNames( typeof(Roles) ).Length];
int index = 0;
foreach( string roleName in Enum.GetNames( typeof(Roles) ) )
{
Role role = new Role( (Roles) Enum.Parse( typeof(Roles), roleName, false ) );
role.Persist();
fixedRoles[ index++ ] = role;
}
}
示例12: TestCRUD_Dog
public void TestCRUD_Dog()
{
o1 = new Dog();
// insert
o1.Persist();
Assert.IsTrue( o1.Id > 0, "No identity assigned on insert." );
// select
o2 = Dog.Retrieve( o1.Id );
// verify select/insert
Assert.IsNotNull( o2.Id, "The object could not be retrieved from the database!" );
Assert.AreEqual( o1.Id, o2.Id, "The object could not be retrieved from the database!" );
// update
o2.Persist();
// verify update
o1 = Dog.Retrieve( o2.Id );
// delete
o2.Remove();
// verify delete by counting the number of rows
SqlBuilder sb = new SqlBuilder( StatementType.Count, typeof(Dog) );
sb.AddConstraint( Operator.Equals, "Id", o1.Id );
SqlResult sr = Broker.Execute( sb.GetStatement( true ) );
Assert.AreEqual( 0, sr.Count, "Object not removed" );
}
示例13: TestCRUD
public void TestCRUD()
{
a = new PropertyHolder( 0, "MyPH", 2, 3, 4, 5.0, true, DateTime.Now, DateTime.Now,
"char", "nchar", "varchar", "nvarchar", "text", "ntext" );
// insert
a.Persist();
Assert.AreEqual( a.Name, "MyPH" );
// select
b = PropertyHolder.Retrieve( a.Id );
// verify select/insert
Assert.IsTrue( b.Id != 0 );
Assert.AreEqual( a.Id, b.Id );
Assert.AreEqual( "MyPH", b.Name );
// update
b.Name = "NewPH";
b.TDateTime = DateTime.MinValue; // should result in DBNull being written
b.Persist();
// verify update
a = Broker.RetrieveInstance( typeof(PropertyHolder), b.GetKey() ) as PropertyHolder;
Assert.AreEqual( b.Name, a.Name );
Assert.AreEqual( DateTime.MinValue, a.TDateTime );
// delete
b.Remove();
// verify delete by counting the number of rows
SqlBuilder sb = new SqlBuilder( StatementType.Count, typeof(PropertyHolder) );
sb.AddConstraint( Operator.Equals, "Id", a.Id );
SqlResult sr = Broker.Execute( sb.GetStatement( true ) );
Assert.AreEqual( 0, sr.Count, "Object not removed" );
}
示例14: Exit
public void Exit()
{
// clean up after running tests
SqlBuilder sb = new SqlBuilder( StatementType.Delete, typeof(PropertyHolder) );
Broker.Execute( sb.GetStatement( true ) );
}
示例15: TestCRUD
public void TestCRUD()
{
// skip test if picture data was not read (check the PATH constant above!)
if( runTest && picture != null )
{
mp1 = new MemberPicture( picture, 1 );
// insert
mp1.Persist();
Assert.AreEqual( mp1.MemberId, 1, "The object was not properly inserted!" );
Assert.AreEqual( GetSize( mp1.Picture ), pictureSize, "The object was not properly inserted!" );
// select
mp2 = MemberPicture.Retrieve( mp1.Id );
// verify select/insert
Assert.IsNotNull( mp2.Id, "The object could not be retrieved from the database!" );
Assert.AreEqual( mp1.Id, mp2.Id, "The object could not be retrieved from the database!" );
Assert.AreEqual( pictureSize, GetSize( mp2.Picture ), "The object was not properly retrieved on construction!" );
Assert.AreEqual( mp1.MemberId, mp2.MemberId,
"The object was not properly retrieved on construction!" );
// update
mp2.MemberId = 2;
mp2.Persist();
// verify update
mp1 = MemberPicture.Retrieve( mp2.Id );
Assert.AreEqual( mp2.MemberId, mp1.MemberId, "MemberId not updated!" );
// delete
mp2.Remove();
// verify delete by counting the number of rows
SqlBuilder sb = new SqlBuilder( StatementType.Count, typeof(MemberPicture) );
sb.AddConstraint( Operator.Equals, "Id", mp1.Id );
SqlResult sr = Broker.Execute( sb.GetStatement( true ) );
Assert.AreEqual( 0, sr.Count, "Object not removed" );
}
}