Skip to content

Commit 126b691

Browse files
committed
Fix ColumnInfoRef bug with implicint convertion from null
1 parent 0e4c9c2 commit 126b691

5 files changed

Lines changed: 8 additions & 19 deletions

File tree

Orm/Xtensive.Orm/Comparison/ComparisonRule.cs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ namespace Xtensive.Comparison
1616
/// Describes how to compare values of comparable objects.
1717
/// </summary>
1818
[Serializable]
19-
public struct ComparisonRule :
19+
public readonly struct ComparisonRule :
2020
IEquatable<ComparisonRule>,
2121
ISerializable
2222
{
@@ -75,12 +75,8 @@ public ComparisonRule Combine(ComparisonRule rule)
7575
#region Equals, GetHashCode
7676

7777
/// <inheritdoc/>
78-
public bool Equals(ComparisonRule other)
79-
{
80-
if (Direction != other.Direction)
81-
return false;
82-
return Equals(Culture, other.Culture);
83-
}
78+
public bool Equals(ComparisonRule other) =>
79+
Direction == other.Direction && Equals(Culture, other.Culture);
8480

8581
/// <inheritdoc/>
8682
public override bool Equals(object obj) =>

Orm/Xtensive.Orm/Orm/Model/ColumnInfoRef.cs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,6 @@ public ColumnInfo Resolve(DomainModel model) =>
5151
? throw new InvalidOperationException(string.Format(Strings.ExCouldNotResolveXYWithinDomain, "field", FieldName))
5252
: field.Column ?? throw new InvalidOperationException(string.Format(Strings.ExCouldNotResolveXYWithinDomain, "column", ColumnName));
5353

54-
/// <summary>
55-
/// Creates reference for <see cref="ColumnInfo"/>.
56-
/// </summary>
57-
public static implicit operator ColumnInfoRef(ColumnInfo columnInfo) =>
58-
new ColumnInfoRef(columnInfo);
59-
6054
#region Equality members, ==, !=
6155

6256
/// <summary>

Orm/Xtensive.Orm/Orm/Rse/MappedColumn.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public override Column Clone(string newName)
5151
/// <param name="index"><see cref="Column.Index"/> property value.</param>
5252
/// <param name="type"><see cref="Column.Type"/> property value.</param>
5353
public MappedColumn(string name, int index, Type type)
54-
: this(null, name, index, type)
54+
: this(default, name, index, type)
5555
{
5656
}
5757

Orm/Xtensive.Orm/Orm/Rse/Providers/Compilable/OrderProviderBase.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,10 @@ protected override void Initialize()
6666
var comparisonRules = new ComparisonRules[Order.Count];
6767
for (int i = 0; i < Order.Count; i++) {
6868
var orderItem = Order[i];
69-
var culture = CultureInfo.InvariantCulture;
7069
var column = Header.Columns[orderItem.Key];
71-
var mappedColumn = column as MappedColumn;
72-
if (mappedColumn != null && mappedColumn.ColumnInfoRef != null)
73-
culture = mappedColumn.ColumnInfoRef.CultureInfo;
70+
var culture = column is MappedColumn mappedColumn && mappedColumn.ColumnInfoRef != default
71+
? mappedColumn.ColumnInfoRef.CultureInfo
72+
: CultureInfo.InvariantCulture;
7473
comparisonRules[i] = new ComparisonRule(orderItem.Value, culture);
7574
}
7675

Orm/Xtensive.Orm/Orm/Rse/RecordSetHeader.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ private static RecordSetHeader CreateHeader(IndexInfo indexInfo)
251251
.ToArray(indexInfoKeyColumns.Count);
252252
var keyDescriptor = TupleDescriptor.Create(keyFieldTypes);
253253

254-
var resultColumns = indexInfoColumns.Select((c,i) => (Column) new MappedColumn(c,i,c.ValueType));
254+
var resultColumns = indexInfoColumns.Select((c,i) => (Column) new MappedColumn(new ColumnInfoRef(c), i,c.ValueType));
255255
var resultGroups = new[]{indexInfo.Group};
256256

257257
return new RecordSetHeader(

0 commit comments

Comments
 (0)