Exemplo n.º 1
0
 public static void AppendQuerySql([NotNull] SqlSerializationContext context, [CanBeNull] IDBPredicate cond)
 {
     context.Write(SelectSql);
     cond = cond != null ? new AndCondtion(AliveRecordsFilter, cond) : AliveRecordsFilter;
     context.Write(" WHERE ");
     cond.Write(context);
 }
Exemplo n.º 2
0
 public static void AppendSelectRangeSql([NotNull] SqlSerializationContext context, int from, int to, IDBPredicate st)
 {
     context.Write(__SelectRangeSqlTemplate_1, context.AddParameter(from), context.AddParameter(to));
     if (st != null)
     {
         st.Write(context);
     }
     context.Write(Environment.NewLine);
     context.Write(__SelectRangeSqlTemplate_2);
 }
Exemplo n.º 3
0
 public void Write(SqlSerializationContext context)
 {
     context.Write("SELECT ");
     context.Write(FieldNames.Select(f => SqlUtils.WrapDbId(f)).ConcatComma());
     context.Write(" FROM ");
     context.Write(SqlUtils.WrapDbId(DataObjectInfo <TDataObject> .TableName));
     if (Condition != null)
     {
         context.Write(" WHERE ");
         Condition.Write(context);
     }
 }
Exemplo n.º 4
0
        public static void AppendLookupSql([NotNull] SqlSerializationContext context, [NotNull] IIntKeyedDataObject owner, [NotNull] Type detailType, [CanBeNull] IDBPredicate condition)
        {
            var r = Get(__Infos, owner.GetType(), detailType);

            if (r.IsEmpty)
            {
                throw new DMError("Couldnt found relation between {0} and {1}", owner.GetType(), detailType);
            }
            if (owner.ID <= 0)
            {
                throw new DMError("{0} has invalid ID = {1}", owner.GetType().Name, owner.ID);
            }

            context.Write("SELECT ID FROM [{0}] where ([{1}] = {2}) and sysState = 0", r.TableName, r.RefColumnName, context.AddParameter(owner.ID));
            if (condition != null)
            {
                context.Write(" AND (");
                condition.Write(context);
                context.Write(")");
            }
        }