Skip to content

Commit c3d8fe2

Browse files
committed
разбор списка полей Индекса для совместимости
1 parent 33a65e9 commit c3d8fe2

File tree

1 file changed

+10
-13
lines changed

1 file changed

+10
-13
lines changed

src/OneScript.StandardLibrary/Collections/ValueTable/CollectionIndexes.cs

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public CollectionIndex Add(string columns)
4040
[ContextMethod("Количество", "Count")]
4141
public override int Count()
4242
{
43-
return _indexes.Count();
43+
return _indexes.Count;
4444
}
4545

4646
[ContextMethod("Удалить", "Delete")]
@@ -130,21 +130,18 @@ public CollectionIndex FindSuitableIndex(IEnumerable<IValue> searchFields)
130130
return _indexes.FirstOrDefault(index => index.CanBeUsedFor(searchFields));
131131
}
132132

133-
private static IList<IValue> BuildFieldList(IIndexCollectionSource source, string fieldList)
133+
private static List<IValue> BuildFieldList(IIndexCollectionSource source, string fieldList)
134134
{
135135
var fields = new List<IValue>();
136-
var fieldNames = fieldList.Split(',');
136+
if (string.IsNullOrEmpty(fieldList))
137+
return fields;
138+
139+
var fieldNames = fieldList.Split(',', System.StringSplitOptions.RemoveEmptyEntries);
137140
foreach (var fieldName in fieldNames)
138-
{
139-
if (!string.IsNullOrWhiteSpace(fieldName))
140-
{
141-
var field = source.GetField(fieldName.Trim());
142-
if (field == null)
143-
{
144-
throw ColumnException.WrongColumnName(fieldName);
145-
}
146-
fields.Add(field);
147-
}
141+
{
142+
var name = fieldName.Trim();
143+
var field = source.GetField(name) ?? throw ColumnException.WrongColumnName(fieldName);
144+
fields.Add(field);
148145
}
149146

150147
return fields;

0 commit comments

Comments
 (0)