using HotelPms.Share.Util;
|
using System.Data.Common;
|
|
namespace HotelPms.Share.Data.Script;
|
|
public class Field
|
{
|
/// <summary>
|
/// 項目名(列名)
|
/// </summary>
|
public string Name { get; set; } = string.Empty;
|
|
/// <summary>
|
/// 説明
|
/// </summary>
|
public string Description { get; set; } = string.Empty;
|
|
/// <summary>
|
/// 型
|
/// 例:NVARCHAR(50)
|
/// </summary>
|
public string DataType { get; set; } = string.Empty;
|
|
/// <summary>
|
/// プライマリーキーかどうか
|
/// </summary>
|
public bool IsPrimaryKey { get; set; } = false;
|
|
/// <summary>
|
/// 自動増加型かどうか
|
/// </summary>
|
public bool IsIdentity { get; set; } = false;
|
|
/// <summary>
|
/// 変更チェック
|
/// ※プライマリーキー変更は手動でしましょう
|
/// </summary>
|
/// <param name="item"></param>
|
/// <returns>0.なし 1.Description 2.DataType 12.両方変更あり</returns>
|
public int CompareTo(Field item)
|
{
|
|
bool type1 = (item.Description.CompareTo(Description) != 0);
|
bool type2 = (item.DataType.Replace("[", string.Empty).Replace("]", string.Empty).ToUpper().CompareTo(DataType.Replace("[", string.Empty).Replace("]", string.Empty).ToUpper()) != 0);
|
|
if (type1 && !type2) { return 1; }
|
else if (!type1 && type2) { return 2; }
|
else if (type1 && type2) { return 12; }
|
else { return 0; }
|
}
|
|
public Field() { }
|
|
public Field(DbDataReader reader)
|
{
|
Name = CConvert.ToString(reader["Name"]);
|
Description = CConvert.ToString(reader["Description"]);
|
DataType = CConvert.ToString(reader["DataType"]);
|
IsPrimaryKey = CConvert.ToInt(reader["IsPrimaryKey"]) == 1;
|
}
|
}
|