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.Data/Schema/ExistingColumn.cs

65 lines
1.5 KiB

2 years ago
using System.Collections.Immutable;
using System.Data;
using System.Reflection;
2 years ago
using Connected.Data.Schema.Sql;
using Connected.Entities.Annotations;
namespace Connected.Data.Schema;
internal class ExistingColumn : ISchemaColumn, IExistingSchemaColumn
{
public ExistingColumn(ISchema schema)
{
Schema = schema;
}
private ISchema Schema { get; }
public string Name { get; set; }
public DbType DataType { get; set; }
public bool IsIdentity { get; set; }
public bool IsVersion { get; set; }
public bool IsUnique { get; set; }
public bool IsIndex { get; set; }
public bool IsPrimaryKey { get; set; }
public string DefaultValue { get; set; }
public int MaxLength { get; set; }
public bool IsNullable { get; set; }
public string DependencyType { get; set; }
public string DependencyProperty { get; set; }
public string Index { get; set; }
public int Precision { get; set; }
public int Scale { get; set; }
public DateKind DateKind { get; set; } = DateKind.DateTime;
public BinaryKind BinaryKind { get; set; } = BinaryKind.VarBinary;
public PropertyInfo Property { get; set; }
2 years ago
public int DatePrecision { get; set; }
public ImmutableArray<string> QueryIndexColumns(string column)
{
if (Schema is not ExistingSchema existing)
return ImmutableArray<string>.Empty;
foreach (var index in existing.Indexes)
{
if (index.Columns.Contains(column, StringComparer.OrdinalIgnoreCase))
return index.Columns.ToImmutableArray();
}
return ImmutableArray<string>.Empty;
}
}