-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Basic FromSql() support in new pipeline
* Parameterization not implemented (see #15750) * FromSqlRaw() and FromSqlInterpolated() are now defined over DbSet<>, not IQueryable<>. FromSql() is still defined over IQueryable<> but throws if not directly on a DbSet<>. Closes #15704
- Loading branch information
Showing
19 changed files
with
285 additions
and
100 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
6 changes: 6 additions & 0 deletions
6
src/EFCore.Relational/Properties/RelationalStrings.Designer.cs
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
69 changes: 69 additions & 0 deletions
69
src/EFCore.Relational/Query/Pipeline/SqlExpressions/FromSqlExpression.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,69 @@ | ||
// Copyright (c) .NET Foundation. All rights reserved. | ||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
||
using System.Linq.Expressions; | ||
using JetBrains.Annotations; | ||
using Microsoft.EntityFrameworkCore.Query.Internal; | ||
|
||
namespace Microsoft.EntityFrameworkCore.Relational.Query.Pipeline.SqlExpressions | ||
{ | ||
public class FromSqlExpression : TableExpressionBase | ||
{ | ||
#region Fields & Constructors | ||
public FromSqlExpression( | ||
[NotNull] string sql, | ||
[NotNull] string alias) | ||
: base(alias) | ||
{ | ||
Sql = sql; | ||
} | ||
#endregion | ||
|
||
#region Public Properties | ||
|
||
/// <summary> | ||
/// Gets the SQL. | ||
/// </summary> | ||
/// <value> | ||
/// The SQL. | ||
/// </value> | ||
public string Sql { get; } | ||
|
||
#endregion | ||
|
||
#region Expression-based methods | ||
|
||
protected override Expression VisitChildren(ExpressionVisitor visitor) | ||
=> this; | ||
|
||
#endregion | ||
|
||
#region Equality & HashCode | ||
|
||
public override bool Equals(object obj) | ||
=> obj != null | ||
&& (ReferenceEquals(this, obj) | ||
|| obj is FromSqlExpression fromSqlExpression | ||
&& Equals(fromSqlExpression)); | ||
|
||
private bool Equals(FromSqlExpression fromSqlExpression) | ||
=> base.Equals(fromSqlExpression) | ||
&& string.Equals(Sql, fromSqlExpression.Sql); | ||
|
||
public override int GetHashCode() | ||
{ | ||
unchecked | ||
{ | ||
var hashCode = base.GetHashCode(); | ||
hashCode = (hashCode * 397) ^ Sql.GetHashCode(); | ||
|
||
return hashCode; | ||
} | ||
} | ||
|
||
#endregion | ||
|
||
public override void Print(ExpressionPrinter expressionPrinter) | ||
=> expressionPrinter.StringBuilder.Append(Sql); | ||
} | ||
} |
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
Oops, something went wrong.