Files
Common-VS2019/SacsStandardBase/Base/Dbas/DbDfnIndexColumn.cs
T
2021-05-05 15:36:28 +01:00

62 lines
1.9 KiB
C#

using Sarand.Net.Standard.Base.Core;
using Sarand.Net.Standard.Base.Utils;
using System;
using System.Collections.Generic;
namespace Sarand.Net.Standard.Base.Dbas
{
//==========================================================================
//[Serializable()]
public class DbDfnIndexColumn
{
//-------------------------------------------------------------------
// Construction.
public DbDfnIndexColumn () { }
public DbDfnIndexColumn (short seq, String name, bool ascend)
{
this.Seq = seq;
this.Name = name;
this.Ascend = ascend;
}
//-------------------------------------------------------------------
// Attributes.
public short Seq { get; set; } = 0;
public String Name { get; set; } = String.Empty;
public bool Ascend { get; set; } = true;
//-------------------------------------------------------------------
}
//==========================================================================
// Index Column list extensions.
public static class DbDfnIndexColumnList
{
//-------------------------------------------------------------------
/// <summary>Compile list of column names.</summary>
public static List<String> GetNames (this List<DbDfnIndexColumn> columns)
{
List<String> names = new List<String>();
foreach (var column in columns)
{
names.Add(column.Name);
}
return names;
}
//-------------------------------------------------------------------
/// <summary>Get position (from 1) for column by name.</summary>
public static int GetPosForName (this List<DbDfnIndexColumn> columns, String columnName)
{
for (int idx = 0; idx < columns.Count; idx++)
foreach (var column in columns)
{
if (columns[idx].Name.EqualsCI(columnName)) return idx + 1;
}
return 0;
}
//-------------------------------------------------------------------
}
//==========================================================================
}