You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Connected.Framework/Connected.Expressions/Expressions/ColumnExpression.cs

46 lines
1.0 KiB

2 years ago
using Connected.Expressions.Languages;
using Connected.Expressions.Translation;
namespace Connected.Expressions;
public sealed class ColumnExpression : DatabaseExpression, IEquatable<ColumnExpression>
{
public ColumnExpression(Type type, DataType dataType, Alias alias, string name)
: base(DatabaseExpressionType.Column, type)
{
if (dataType is null)
throw new ArgumentNullException(nameof(dataType));
if (name is null)
throw new ArgumentNullException(nameof(name));
Alias = alias;
Name = name;
QueryType = dataType;
}
public Alias Alias { get; }
public string Name { get; }
public DataType QueryType { get; }
public override string ToString()
{
return $"{Alias}.C({Name})";
}
public override int GetHashCode()
{
return Alias.GetHashCode() + Name.GetHashCode();
}
public override bool Equals(object? obj)
{
return Equals(obj as ColumnExpression);
}
public bool Equals(ColumnExpression? other)
{
return other is not null && (this) == other || (Alias == other?.Alias && Name == other.Name);
}
}