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); }
public static void AppendUpdateSql([NotNull] SqlSerializationContext context, [NotNull] TDataObject instance) { context.Write(UpdateSqlHeader + (from ci in DataObjectInfo <TDataObject> .Columns where ci.Name != "ID" select SqlUtils.WrapDbId(ci.Name) + "=" + context.AddParameter(ci.Storage.GetValue(instance)) ).ConcatComma() + " WHERE ID=" + instance.ID); }
public static void AppendInsertSql([NotNull] SqlSerializationContext context, [NotNull] TDataObject obj) { context.Write(InsertSqlHeader); context.Write( SqlUtils.WrapArc( (from ci in DataObjectInfo <TDataObject> .Columns where ci.Name != "ID" select context.AddParameter(ci.Storage.GetValue(obj)) ).ConcatComma() ) ); context.Next(); context.Write("select SCOPE_IDENTITY()"); }
public static void AppendMMLookupSql([NotNull] SqlSerializationContext context, IIntKeyedDataObject firstPart, Type otherType) { var r = Get(__MMInfos, firstPart.GetType(), otherType); if (r.IsEmpty) { throw new DMError("Couldnt fond many-to-many relation between {1} and {1}", firstPart.GetType().Name, otherType.Name); } if (firstPart.ID <= 0) { throw new DMError("{0} has invalid ID = {1}", firstPart.GetType(), firstPart.ID); } context.Write("SELECT [{0}] FROM [{1}] WHERE ([{2}] = {3}) and sysState = 0", r.IDColumnName, r.TableName, r.RefColumnName, context.AddParameter(firstPart.ID)); }
public static void AppendMMLookupSql([NotNull] SqlSerializationContext context, IIntKeyedDataObject firstPart, Type otherType) { var r = Get(__MMInfos, firstPart.GetType(), otherType); if (r.IsEmpty) { throw new DMError(Translations.LookupHelper_AppendMMLookupSql_Couldnt_fond_many_to_many_relation_between__1__and__1_, firstPart.GetType().Name, otherType.Name); } if (firstPart.ID <= 0) { throw new DMError(Translations.LookupHelper_AppendLookupSql_, firstPart.GetType(), firstPart.ID); } context.Write("SELECT [{0}] FROM [{1}] WHERE ([{2}] = {3}) and sysState = 0", r.IDColumnName, r.TableName, r.RefColumnName, context.AddParameter(firstPart.ID)); }
public void Write(SqlSerializationContext context) { bool notFirst = false; context.Write("("); foreach (var p in _Param.GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public)) { if (notFirst) { context.Write(" AND "); } else { notFirst = true; } context.Write("([{0}] = {1})", p.Name, context.AddParameter(p.GetValue(_Param, null))); } context.Write(")"); }
public static void AppendMMLinkSql([NotNull] SqlSerializationContext context, IIntKeyedDataObject o1, IIntKeyedDataObject o2) { if (o1.ID <= 0) { throw new DMError("{0} has invalid ID = {1}", o1.GetType(), o1.ID); } if (o2.ID <= 0) { throw new DMError("{0} has invalid ID = {1}", o2.GetType(), o2.ID); } var r = Get(__MMInfos, o1.GetType(), o2.GetType()); if (r.IsEmpty) { throw new DMError("Couldnt fond many-to-many relation between {1} and {1}", o1.GetType().Name, o2.GetType().Name); } context.Write("INSERT INTO [{0}] ([{1}], [{2}]) VALUES ({3}, {4})", r.TableName, r.RefColumnName, r.IDColumnName, context.AddParameter(o1.ID), context.AddParameter(o2.ID)); }
public static void AppendMMUnLinkSql([NotNull] SqlSerializationContext context, IIntKeyedDataObject o1, IIntKeyedDataObject o2) { var r = Get(__MMInfos, o1.GetType(), o2.GetType()); if (r.IsEmpty) { throw new DMError(Translations.LookupHelper_AppendMMLookupSql_Couldnt_fond_many_to_many_relation_between__1__and__1_, o1.GetType().Name, o2.GetType().Name); } if (o1.ID <= 0) { throw new DMError(Translations.LookupHelper_AppendLookupSql_, o1.GetType(), o1.ID); } if (o2.ID <= 0) { throw new DMError(Translations.LookupHelper_AppendLookupSql_, o2.GetType(), o2.ID); } context.Write("DELETE [{0}] WHERE [{1}] = {3} AND [{2}] = {4}", r.TableName, r.RefColumnName, r.IDColumnName, context.AddParameter(o1.ID), context.AddParameter(o2.ID)); }
public void Write(SqlSerializationContext context) { context.Write(context.AddParameter(Value)); }
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(")"); } }