Manual fix for more backward compatibility

This commit is contained in:
2026-02-26 19:38:28 +01:00
parent 13936d8598
commit 15e1d9031c
8 changed files with 1204 additions and 107 deletions

View File

@@ -49,18 +49,6 @@ namespace DynamORM.Builders
/// <returns>Builder instance.</returns>
IDynamicTypedSelectQueryBuilder<T> Join<TRight>(Func<TypedJoinBuilder<T, TRight>, TypedJoinBuilder<T, TRight>> specification);
/// <summary>Add INNER JOIN using typed ON predicate.</summary>
IDynamicTypedSelectQueryBuilder<T> InnerJoin<TRight>(Expression<Func<T, TRight, bool>> on, string alias = null);
/// <summary>Add LEFT JOIN using typed ON predicate.</summary>
IDynamicTypedSelectQueryBuilder<T> LeftJoin<TRight>(Expression<Func<T, TRight, bool>> on, string alias = null);
/// <summary>Add RIGHT JOIN using typed ON predicate.</summary>
IDynamicTypedSelectQueryBuilder<T> RightJoin<TRight>(Expression<Func<T, TRight, bool>> on, string alias = null);
/// <summary>Add FULL JOIN using typed ON predicate.</summary>
IDynamicTypedSelectQueryBuilder<T> FullJoin<TRight>(Expression<Func<T, TRight, bool>> on, string alias = null);
/// <summary>Add typed where predicate using mapped properties.</summary>
/// <param name="predicate">Predicate to parse.</param>
/// <returns>Builder instance.</returns>

View File

@@ -118,26 +118,6 @@ namespace DynamORM.Builders.Implementation
return Join(spec.OnPredicate, spec.Alias, spec.JoinType);
}
public IDynamicTypedSelectQueryBuilder<T> InnerJoin<TRight>(Expression<Func<T, TRight, bool>> on, string alias = null)
{
return Join(on, alias, DynamicJoinType.Inner);
}
public IDynamicTypedSelectQueryBuilder<T> LeftJoin<TRight>(Expression<Func<T, TRight, bool>> on, string alias = null)
{
return Join(on, alias, DynamicJoinType.Left);
}
public IDynamicTypedSelectQueryBuilder<T> RightJoin<TRight>(Expression<Func<T, TRight, bool>> on, string alias = null)
{
return Join(on, alias, DynamicJoinType.Right);
}
public IDynamicTypedSelectQueryBuilder<T> FullJoin<TRight>(Expression<Func<T, TRight, bool>> on, string alias = null)
{
return Join(on, alias, DynamicJoinType.Full);
}
public new IDynamicTypedSelectQueryBuilder<T> Join(params Func<dynamic, object>[] func)
{
base.Join(func);

View File

@@ -453,28 +453,52 @@ namespace DynamORM
/// <param name="alias">Table alias.</param>
/// <param name="noLock">use no lock.</param>
/// <returns>This instance to permit chaining.</returns>
public virtual IDynamicTypedSelectQueryBuilder<T> From<T>(string alias = null, bool noLock = false)
{
// TODO: Make it more readable and maitainable
DynamicTypedSelectQueryBuilder<T> builder = new DynamicTypedSelectQueryBuilder<T>(this);
if (noLock)
{
if (string.IsNullOrEmpty(alias))
builder.From(x => x(typeof(T)).NoLock());
else
builder.From(x => x(typeof(T)).As(alias).NoLock());
}
else
{
if (string.IsNullOrEmpty(alias))
builder.From(x => x(typeof(T)));
else
builder.From(x => x(typeof(T)).As(alias));
}
return builder;
}
public virtual IDynamicSelectQueryBuilder From<T>(string alias = null, bool noLock = false)
{
// TODO: Make it more readable and maitainable
if (noLock)
{
if (string.IsNullOrEmpty(alias))
return new DynamicSelectQueryBuilder(this).From(x => x(typeof(T)).NoLock());
else
return new DynamicSelectQueryBuilder(this).From(x => x(typeof(T)).As(alias).NoLock());
}
else
{
if (string.IsNullOrEmpty(alias))
return new DynamicSelectQueryBuilder(this).From(x => x(typeof(T)));
else
return new DynamicSelectQueryBuilder(this).From(x => x(typeof(T)).As(alias));
}
}
/// <summary>Adds to the <code>FROM</code> clause using <see cref="Type"/>.</summary>
/// <typeparam name="T">Type which can be represented in database.</typeparam>
/// <param name="alias">Table alias.</param>
/// <param name="noLock">use no lock.</param>
/// <returns>This instance to permit chaining.</returns>
public virtual IDynamicTypedSelectQueryBuilder<T> FromTyped<T>(string alias = null, bool noLock = false)
{
// TODO: Make it more readable and maitainable
DynamicTypedSelectQueryBuilder<T> builder = new DynamicTypedSelectQueryBuilder<T>(this);
if (noLock)
{
if (string.IsNullOrEmpty(alias))
builder.From(x => x(typeof(T)).NoLock());
else
builder.From(x => x(typeof(T)).As(alias).NoLock());
}
else
{
if (string.IsNullOrEmpty(alias))
builder.From(x => x(typeof(T)));
else
builder.From(x => x(typeof(T)).As(alias));
}
return builder;
}
/// <summary>Adds to the <code>FROM</code> clause using <see cref="Type"/>.</summary>
/// <param name="t">Type which can be represented in database.</param>
@@ -503,12 +527,20 @@ namespace DynamORM
/// <summary>Adds to the <code>INSERT INTO</code> clause using <see cref="Type"/>.</summary>
/// <typeparam name="T">Type which can be represented in database.</typeparam>
/// <returns>This instance to permit chaining.</returns>
public virtual IDynamicTypedInsertQueryBuilder<T> Insert<T>()
{
DynamicTypedInsertQueryBuilder<T> builder = new DynamicTypedInsertQueryBuilder<T>(this);
builder.Table(typeof(T));
return builder;
}
public virtual IDynamicInsertQueryBuilder Insert<T>()
{
return new DynamicInsertQueryBuilder(this).Table(typeof(T));
}
/// <summary>Adds to the <code>INSERT INTO</code> clause using <see cref="Type"/>.</summary>
/// <typeparam name="T">Type which can be represented in database.</typeparam>
/// <returns>This instance to permit chaining.</returns>
public virtual IDynamicTypedInsertQueryBuilder<T> InsertTyped<T>()
{
DynamicTypedInsertQueryBuilder<T> builder = new DynamicTypedInsertQueryBuilder<T>(this);
builder.Table(typeof(T));
return builder;
}
/// <summary>Adds to the <code>INSERT INTO</code> clause using <see cref="Type"/>.</summary>
/// <param name="t">Type which can be represented in database.</param>
@@ -612,12 +644,20 @@ namespace DynamORM
/// <summary>Adds to the <code>UPDATE</code> clause using <see cref="Type"/>.</summary>
/// <typeparam name="T">Type which can be represented in database.</typeparam>
/// <returns>This instance to permit chaining.</returns>
public virtual IDynamicTypedUpdateQueryBuilder<T> Update<T>()
{
DynamicTypedUpdateQueryBuilder<T> builder = new DynamicTypedUpdateQueryBuilder<T>(this);
builder.Table(typeof(T));
return builder;
}
public virtual IDynamicUpdateQueryBuilder Update<T>()
{
return new DynamicUpdateQueryBuilder(this).Table(typeof(T));
}
/// <summary>Adds to the <code>UPDATE</code> clause using <see cref="Type"/>.</summary>
/// <typeparam name="T">Type which can be represented in database.</typeparam>
/// <returns>This instance to permit chaining.</returns>
public virtual IDynamicTypedUpdateQueryBuilder<T> UpdateTyped<T>()
{
DynamicTypedUpdateQueryBuilder<T> builder = new DynamicTypedUpdateQueryBuilder<T>(this);
builder.Table(typeof(T));
return builder;
}
/// <summary>Adds to the <code>UPDATE</code> clause using <see cref="Type"/>.</summary>
/// <param name="t">Type which can be represented in database.</param>
@@ -835,12 +875,20 @@ namespace DynamORM
/// <summary>Adds to the <code>DELETE FROM</code> clause using <see cref="Type"/>.</summary>
/// <typeparam name="T">Type which can be represented in database.</typeparam>
/// <returns>This instance to permit chaining.</returns>
public virtual IDynamicTypedDeleteQueryBuilder<T> Delete<T>()
{
DynamicTypedDeleteQueryBuilder<T> builder = new DynamicTypedDeleteQueryBuilder<T>(this);
builder.Table(typeof(T));
return builder;
}
public virtual IDynamicDeleteQueryBuilder Delete<T>()
{
return new DynamicDeleteQueryBuilder(this).Table(typeof(T));
}
/// <summary>Adds to the <code>DELETE FROM</code> clause using <see cref="Type"/>.</summary>
/// <typeparam name="T">Type which can be represented in database.</typeparam>
/// <returns>This instance to permit chaining.</returns>
public virtual IDynamicTypedDeleteQueryBuilder<T> DeleteTyped<T>()
{
DynamicTypedDeleteQueryBuilder<T> builder = new DynamicTypedDeleteQueryBuilder<T>(this);
builder.Table(typeof(T));
return builder;
}
/// <summary>Adds to the <code>DELETE FROM</code> clause using <see cref="Type"/>.</summary>
/// <param name="t">Type which can be represented in database.</param>
@@ -2016,16 +2064,16 @@ namespace DynamORM
#region IExtendedDisposable Members
/// <summary>Performs application-defined tasks associated with freeing,
/// releasing, or resetting unmanaged resources.</summary>
public void Dispose()
{
if (IsDisposed)
return;
#if !DYNAMORM_OMMIT_OLDSYNTAX
List<DynamicTable> tables = TablesCache.Values.ToList();
TablesCache.Clear();
/// <summary>Performs application-defined tasks associated with freeing,
/// releasing, or resetting unmanaged resources.</summary>
public void Dispose()
{
if (IsDisposed)
return;
#if !DYNAMORM_OMMIT_OLDSYNTAX
List<DynamicTable> tables = TablesCache.Values.ToList();
TablesCache.Clear();
tables.ForEach(t => t.Dispose());
tables.Clear();
@@ -2076,18 +2124,18 @@ namespace DynamORM
RemainingBuilders = null;
}
ClearSchema();
if (_proc != null)
_proc.Dispose();
_proc = null;
_tempConn = null;
IsDisposed = true;
}
ClearSchema();
if (_proc != null)
_proc.Dispose();
_proc = null;
_tempConn = null;
IsDisposed = true;
}
/// <summary>Gets a value indicating whether this instance is disposed.</summary>
public bool IsDisposed { get; private set; }
#endregion IExtendedDisposable Members
}
}
}