Skip to content

Commit

Permalink
Delete is now a method, add generic overload
Browse files Browse the repository at this point in the history
  • Loading branch information
Quin Lynch committed Apr 27, 2024
1 parent a84bc69 commit 4a1aaaa
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
8 changes: 7 additions & 1 deletion src/EdgeDB.Net.QueryBuilder/Interfaces/IQueryBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,13 @@ ISelectQuery<TShape, TContext> SelectExpression<TExpression, TShape>(
/// <summary>
/// Adds a <c>DELETE</c> statement deleting an instance of <typeparamref name="TType"/>.
/// </summary>
IDeleteQuery<TType, TContext> Delete { get; }
IDeleteQuery<TType, TContext> Delete();

/// <summary>
/// Adds a <c>DELETE</c> statement deleting an instance of <typeparamref name="TType"/>.
/// </summary>
/// <typeparam name="TNewType">The type to delete.</typeparam>
IDeleteQuery<TNewType, TContext> Delete<TNewType>();
}

/// <summary>
Expand Down
19 changes: 11 additions & 8 deletions src/EdgeDB.Net.QueryBuilder/QueryBuilder/QueryBuilder.Delete.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,23 @@ public static partial class QueryBuilder
{
/// <inheritdoc cref="IQueryBuilder{TType, QueryContext}.Delete"/>
public static IDeleteQuery<TType, QueryContextSelf<TType>> Delete<TType>()
=> new QueryBuilder<TType>().Delete;
=> new QueryBuilder<TType>().Delete();
}

public partial class QueryBuilder<TType, TContext>
{
/// <inheritdoc/>
[DebuggerHidden]
public IDeleteQuery<TType, TContext> Delete
public IDeleteQuery<TType, TContext> Delete()
{
get
{
AddNode<DeleteNode>(new DeleteContext(typeof(TType)));
return this;
}
AddNode<DeleteNode>(new DeleteContext(typeof(TType)));
return this;
}

/// <inheritdoc/>
public IDeleteQuery<TNewType, TContext> Delete<TNewType>()
{
AddNode<DeleteNode>(new DeleteContext(typeof(TNewType)));
return EnterNewType<TNewType>();
}

IDeleteQuery<TType, TContext> IDeleteQuery<TType, TContext>.Filter(Expression<Func<TType, bool>> filter)
Expand Down

0 comments on commit 4a1aaaa

Please sign in to comment.