Skip to content

Commit

Permalink
temp
Browse files Browse the repository at this point in the history
  • Loading branch information
smitpatel committed Mar 29, 2017
1 parent 39a56bd commit a7e7c94
Show file tree
Hide file tree
Showing 15 changed files with 218 additions and 159 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -484,13 +484,10 @@ private static void LiftOrderBy(

foreach (var ordering in orderings)
{
var orderingExpression = ordering.Expression;

var projection = innerJoinSelectExpression.Projection[innerJoinSelectExpression.AddToProjection(orderingExpression)];

var newExpression = projection.LiftExpressionFromSubquery(innerJoinExpression);

targetSelectExpression.AddToOrderBy(new Ordering(newExpression, ordering.OrderingDirection));
targetSelectExpression.AddToOrderBy(
new Ordering(
innerJoinSelectExpression.Projection[innerJoinSelectExpression.AddToProjection(ordering.Expression)]
.LiftExpressionFromSubquery(innerJoinExpression), ordering.OrderingDirection));
}

if (innerJoinSelectExpression.Limit == null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ protected override Expression Accept(ExpressionVisitor visitor)
}

/// <summary>
/// Reduces the node and then calls the <see cref="ExpressionVisitor.Visit(System.Linq.Expressions.Expression)" /> method passing the
/// Reduces the node and then calls the <see cref="ExpressionVisitor.Visit(Expression)" /> method passing the
/// reduced expression.
/// Throws an exception if the node isn't reducible.
/// </summary>
Expand Down
43 changes: 43 additions & 0 deletions src/EFCore.Relational/Query/Expressions/CrossJoinExpression.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,49 @@ protected override Expression Accept(ExpressionVisitor visitor)
: base.Accept(visitor);
}

/// <summary>
/// Tests if this object is considered equal to another.
/// </summary>
/// <param name="obj"> The object to compare with the current object. </param>
/// <returns>
/// true if the objects are considered equal, false if they are not.
/// </returns>
public override bool Equals(object obj)
{
if (ReferenceEquals(null, obj))
{
return false;
}

if (ReferenceEquals(this, obj))
{
return true;
}

return obj.GetType() == GetType() && Equals((CrossJoinExpression)obj);
}

private bool Equals(CrossJoinExpression other)
=> string.Equals(Alias, other.Alias)
&& Equals(QuerySource, other.QuerySource);

/// <summary>
/// Returns a hash code for this object.
/// </summary>
/// <returns>
/// A hash code for this object.
/// </returns>
public override int GetHashCode()
{
unchecked
{
var hashCode = Alias?.GetHashCode() ?? 0;
hashCode = (hashCode * 397) ^ (QuerySource?.GetHashCode() ?? 0);

return hashCode;
}
}

/// <summary>
/// Creates a <see cref="string" /> representation of the Expression.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,49 @@ protected override Expression Accept(ExpressionVisitor visitor)
: base.Accept(visitor);
}

/// <summary>
/// Tests if this object is considered equal to another.
/// </summary>
/// <param name="obj"> The object to compare with the current object. </param>
/// <returns>
/// true if the objects are considered equal, false if they are not.
/// </returns>
public override bool Equals(object obj)
{
if (ReferenceEquals(null, obj))
{
return false;
}

if (ReferenceEquals(this, obj))
{
return true;
}

return obj.GetType() == GetType() && Equals((CrossJoinLateralExpression)obj);
}

private bool Equals(CrossJoinLateralExpression other)
=> string.Equals(Alias, other.Alias)
&& Equals(QuerySource, other.QuerySource);

/// <summary>
/// Returns a hash code for this object.
/// </summary>
/// <returns>
/// A hash code for this object.
/// </returns>
public override int GetHashCode()
{
unchecked
{
var hashCode = Alias?.GetHashCode() ?? 0;
hashCode = (hashCode * 397) ^ (QuerySource?.GetHashCode() ?? 0);

return hashCode;
}
}

/// <summary>
/// Creates a <see cref="string" /> representation of the Expression.
/// </summary>
Expand Down
6 changes: 4 additions & 2 deletions src/EFCore.Relational/Query/Expressions/FromSqlExpression.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ public override bool Equals(object obj)
}

private bool Equals(FromSqlExpression other)
=> base.Equals(other)
=> string.Equals(Alias, other.Alias)
&& Equals(QuerySource, other.QuerySource)
&& string.Equals(Sql, other.Sql)
&& Equals(Arguments, other.Arguments);

Expand All @@ -104,7 +105,8 @@ public override int GetHashCode()
{
unchecked
{
var hashCode = base.GetHashCode();
var hashCode = Alias?.GetHashCode() ?? 0;
hashCode = (hashCode * 397) ^ (QuerySource?.GetHashCode() ?? 0);
hashCode = (hashCode * 397) ^ Sql.GetHashCode();
hashCode = (hashCode * 397) ^ Arguments.GetHashCode();

Expand Down
45 changes: 45 additions & 0 deletions src/EFCore.Relational/Query/Expressions/InnerJoinExpression.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,51 @@ protected override Expression Accept(ExpressionVisitor visitor)
: base.Accept(visitor);
}

/// <summary>
/// Tests if this object is considered equal to another.
/// </summary>
/// <param name="obj"> The object to compare with the current object. </param>
/// <returns>
/// true if the objects are considered equal, false if they are not.
/// </returns>
public override bool Equals(object obj)
{
if (ReferenceEquals(null, obj))
{
return false;
}

if (ReferenceEquals(this, obj))
{
return true;
}

return obj.GetType() == GetType() && Equals((InnerJoinExpression)obj);
}

private bool Equals(InnerJoinExpression other)
=> string.Equals(Alias, other.Alias)
&& Equals(QuerySource, other.QuerySource)
&& Equals(Predicate, other.Predicate);

/// <summary>
/// Returns a hash code for this object.
/// </summary>
/// <returns>
/// A hash code for this object.
/// </returns>
public override int GetHashCode()
{
unchecked
{
var hashCode = Alias?.GetHashCode() ?? 0;
hashCode = (hashCode * 397) ^ (QuerySource?.GetHashCode() ?? 0);
hashCode = (hashCode * 397) ^ (Predicate?.GetHashCode() ?? 0);

return hashCode;
}
}

/// <summary>
/// Creates a <see cref="string" /> representation of the Expression.
/// </summary>
Expand Down
45 changes: 45 additions & 0 deletions src/EFCore.Relational/Query/Expressions/LeftOuterJoinExpression.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,51 @@ protected override Expression Accept(ExpressionVisitor visitor)
: base.Accept(visitor);
}

/// <summary>
/// Tests if this object is considered equal to another.
/// </summary>
/// <param name="obj"> The object to compare with the current object. </param>
/// <returns>
/// true if the objects are considered equal, false if they are not.
/// </returns>
public override bool Equals(object obj)
{
if (ReferenceEquals(null, obj))
{
return false;
}

if (ReferenceEquals(this, obj))
{
return true;
}

return obj.GetType() == GetType() && Equals((LeftOuterJoinExpression)obj);
}

private bool Equals(LeftOuterJoinExpression other)
=> string.Equals(Alias, other.Alias)
&& Equals(QuerySource, other.QuerySource)
&& Equals(Predicate, other.Predicate);

/// <summary>
/// Returns a hash code for this object.
/// </summary>
/// <returns>
/// A hash code for this object.
/// </returns>
public override int GetHashCode()
{
unchecked
{
var hashCode = Alias?.GetHashCode() ?? 0;
hashCode = (hashCode * 397) ^ (QuerySource?.GetHashCode() ?? 0);
hashCode = (hashCode * 397) ^ (Predicate?.GetHashCode() ?? 0);

return hashCode;
}
}

/// <summary>
/// Creates a <see cref="string" /> representation of the Expression.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,45 +61,5 @@ protected override Expression VisitChildren(ExpressionVisitor visitor)

return this;
}

/// <summary>
/// Tests if this object is considered equal to another.
/// </summary>
/// <param name="obj"> The object to compare with the current object. </param>
/// <returns>
/// true if the objects are considered equal, false if they are not.
/// </returns>
public override bool Equals(object obj)
{
if (ReferenceEquals(null, obj))
{
return false;
}

if (ReferenceEquals(this, obj))
{
return true;
}

return obj.GetType() == GetType() && Equals((PredicateJoinExpressionBase)obj);
}

private bool Equals(PredicateJoinExpressionBase other)
=> base.Equals(other) && Equals(_predicate, other._predicate);

/// <summary>
/// Returns a hash code for this object.
/// </summary>
/// <returns>
/// A hash code for this object.
/// </returns>
public override int GetHashCode()
{
unchecked
{
// ReSharper disable once NonReadonlyMemberInGetHashCode
return (base.GetHashCode() * 397) ^ (_predicate?.GetHashCode() ?? 0);
}
}
}
}
Loading

0 comments on commit a7e7c94

Please sign in to comment.