Esempio n. 1
0
 private int ProcessHasAndBelongsToMany(IDbObject obj)
 {
     int ret = 0;
     foreach (CrossTable mt in Info.CrossTables.Values)
     {
         var sb = new DeleteStatementBuilder(mt.Name);
         sb.Where.Conditions = CK.K[mt[0].Column] == Handler.GetKeyValue(obj);
         var sql = sb.ToSqlStatement(Provider.Dialect, Info.QueryRequiredFields, Info.AllowSqlLog);
         ret += Provider.ExecuteNonQuery(sql);
     }
     return ret;
 }
Esempio n. 2
0
 private void RemoveManyToManyRelation(Type t, object key1, object key2)
 {
     if ((Info.CrossTables.ContainsKey(t) && (key1 != null)) && (key2 != null))
     {
         CrossTable table = Info.CrossTables[t];
         var builder = new DeleteStatementBuilder(table.Name);
         var condition = (Condition)(CK.K[table[0].Column] == key1);
         condition &= CK.K[table[1].Column] == key2;
         builder.Where.Conditions = condition;
         var sql = builder.ToSqlStatement(Provider.Dialect, Info.QueryRequiredFields, Info.AllowSqlLog);
         Provider.ExecuteNonQuery(sql);
     }
 }
Esempio n. 3
0
 public static void Delete()
 {
     var sb = new DeleteStatementBuilder("SampleData");
     sb.Where.Conditions = (CK.K["Id"] > 9);
     DbEntry.Provider.ExecuteNonQuery(sb.ToSqlStatement(DbEntry.Provider.Dialect, null));
 }
Esempio n. 4
0
 public virtual SqlStatement GetDeleteStatement(object obj)
 {
     var builder = new DeleteStatementBuilder(this.Context.Info.From.MainTableName);
     builder.Where.Conditions = ModelContext.GetKeyWhereClause(obj);
     return builder.ToSqlStatement(this.Context);
 }
Esempio n. 5
0
 public virtual SqlStatement GetDeleteStatement(Condition iwc)
 {
     var builder = new DeleteStatementBuilder(this.Context.Info.From.MainTableName);
     builder.Where.Conditions = iwc;
     return builder.ToSqlStatement(this.Context);
 }
Esempio n. 6
0
		public void TestDeleteSentenceBuilder2()
		{
			var dsb = new DeleteStatementBuilder( "UserTable" );
			dsb.Where.Conditions = new OrClause("ID", 3, 1);
            const string Exp = "DELETE FROM [UserTable] WHERE ([ID] = @ID_0) OR ([ID] = @ID_1);\n<Text><30>(@ID_0=3:Int32,@ID_1=1:Int32)";
            TesterHelper.AssertSqlSentenceEqual(Exp, dsb.ToSqlStatement(dd, null).ToString());
		}
Esempio n. 7
0
		public void TestDeleteSentenceBuilder1()
		{
			var dsb = new DeleteStatementBuilder( "UserTable" );
			const string s = "DELETE FROM [UserTable];";
            TesterHelper.AssertSqlSentenceEqual(dsb.ToSqlStatement(dd, null).SqlCommandText, s);
		}