-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature/common table references logic for all triggers (#83)
* define new triggers API * remove ArgumentTypes from the project --------- Co-authored-by: Ilya Belyanskiy <win7user20@gmail.com>
- Loading branch information
1 parent
846d062
commit b5a4fe9
Showing
250 changed files
with
4,086 additions
and
4,019 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 14 additions & 13 deletions
27
src/Laraue.EfCoreTriggers.Common/CSharpMethods/BinaryFunctions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,22 @@ | ||
using System.Linq.Expressions; | ||
|
||
namespace Laraue.EfCoreTriggers.Common.CSharpMethods; | ||
|
||
/// <summary> | ||
/// Helper for binary functions translation. | ||
/// </summary> | ||
public static class BinaryFunctions | ||
namespace Laraue.EfCoreTriggers.Common.CSharpMethods | ||
{ | ||
/// <summary> | ||
/// Translation of the <see cref="ExpressionType.Coalesce"/> binary. | ||
/// Helper for binary functions translation. | ||
/// </summary> | ||
/// <param name="value"></param> | ||
/// <param name="valueIfNull"></param> | ||
/// <typeparam name="T"></typeparam> | ||
/// <returns></returns> | ||
public static T Coalesce<T>(T value, T valueIfNull) | ||
public static class BinaryFunctions | ||
{ | ||
return value ?? valueIfNull; | ||
/// <summary> | ||
/// Translation of the <see cref="ExpressionType.Coalesce"/> binary. | ||
/// </summary> | ||
/// <param name="value"></param> | ||
/// <param name="valueIfNull"></param> | ||
/// <typeparam name="T"></typeparam> | ||
/// <returns></returns> | ||
public static T Coalesce<T>(T value, T valueIfNull) | ||
{ | ||
return value ?? valueIfNull; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...e.EfCoreTriggers.Common/Converters/MethodCall/CSharpMethods/BaseBinaryFunctionsVisitor.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 27 additions & 21 deletions
48
src/Laraue.EfCoreTriggers.Common/Converters/MethodCall/Enumerable/Count/CountVisitor.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,35 @@ | ||
using System.Linq; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Linq.Expressions; | ||
using Laraue.EfCoreTriggers.Common.Services; | ||
using Laraue.EfCoreTriggers.Common.Services.Impl.ExpressionVisitors; | ||
using Laraue.EfCoreTriggers.Common.SqlGeneration; | ||
using Laraue.EfCoreTriggers.Common.TriggerBuilders; | ||
using Laraue.EfCoreTriggers.Common.Visitors.ExpressionVisitors; | ||
|
||
namespace Laraue.EfCoreTriggers.Common.Converters.MethodCall.Enumerable.Count; | ||
|
||
public class CountVisitor : BaseEnumerableVisitor | ||
namespace Laraue.EfCoreTriggers.Common.Converters.MethodCall.Enumerable.Count | ||
{ | ||
protected override string MethodName => nameof(System.Linq.Enumerable.Count); | ||
|
||
private readonly IExpressionVisitorFactory _expressionVisitorFactory; | ||
|
||
public CountVisitor( | ||
IExpressionVisitorFactory visitorFactory, | ||
IDbSchemaRetriever schemaRetriever, | ||
ISqlGenerator sqlGenerator) | ||
: base(visitorFactory, schemaRetriever, sqlGenerator) | ||
/// <inheritdoc /> | ||
public sealed class CountVisitor : BaseEnumerableVisitor | ||
{ | ||
_expressionVisitorFactory = visitorFactory; | ||
} | ||
/// <inheritdoc /> | ||
protected override string MethodName => nameof(System.Linq.Enumerable.Count); | ||
|
||
/// <summary> | ||
/// Initializes a new instance of <see cref="CountVisitor"/>. | ||
/// </summary> | ||
/// <param name="visitorFactory"></param> | ||
/// <param name="schemaRetriever"></param> | ||
/// <param name="sqlGenerator"></param> | ||
public CountVisitor( | ||
IExpressionVisitorFactory visitorFactory, | ||
IDbSchemaRetriever schemaRetriever, | ||
ISqlGenerator sqlGenerator) | ||
: base(visitorFactory, schemaRetriever, sqlGenerator) | ||
{ | ||
} | ||
|
||
protected override (SqlBuilder, Expression) Visit(Expression[] arguments, ArgumentTypes argumentTypes, VisitedMembers visitedMembers) | ||
{ | ||
return (SqlBuilder.FromString("count(*)"), arguments.FirstOrDefault()); | ||
/// <inheritdoc /> | ||
protected override (SqlBuilder, Expression) Visit(IEnumerable<Expression> arguments, VisitedMembers visitedMembers) | ||
{ | ||
return (SqlBuilder.FromString("count(*)"), arguments.FirstOrDefault()); | ||
} | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
...raue.EfCoreTriggers.Common/Converters/MethodCall/Functions/BaseTriggerFunctionsVisitor.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
using System; | ||
using Laraue.EfCoreTriggers.Common.Functions; | ||
using Laraue.EfCoreTriggers.Common.Visitors.ExpressionVisitors; | ||
|
||
namespace Laraue.EfCoreTriggers.Common.Converters.MethodCall.Functions | ||
{ | ||
/// <summary> | ||
/// Base visitor for the <see cref="TriggerFunctions"/>. | ||
/// </summary> | ||
public abstract class BaseTriggerFunctionsVisitor : BaseMethodCallVisitor | ||
{ | ||
/// Initializes a new instance of <see cref="BaseTriggerFunctionsVisitor"/>. | ||
protected BaseTriggerFunctionsVisitor(IExpressionVisitorFactory visitorFactory) | ||
: base(visitorFactory) | ||
{ | ||
} | ||
|
||
/// <inheritdoc /> | ||
protected override Type ReflectedType => typeof(TriggerFunctions); | ||
} | ||
} |
Oops, something went wrong.