You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

74 lines
2.0 KiB
C#

2 years ago
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Estsh.Core.CodeGenerate
{
public class TableInfo
{
/// <summary>
/// 表格ID表的名称。
/// </summary>
public string TableName { get; set; }
/// <summary>
/// 表的别称,或者描述
/// </summary>
public string Description { get; set; }
/// <summary>
/// 字段列表
/// </summary>
public List<FieldInfo> Fileds { get; set; }
/// <summary>
/// 初始化
/// </summary>
public TableInfo()
{
Fileds = new List<FieldInfo>();
}
/// <summary>
/// 获取主键的名称列表。
/// </summary>
/// <returns></returns>
public List<string> GetIdentityList()
{
var list = Fileds.Where(x => x.IsIdentity);
if (list == null) return null;
return list.Select(x => x.FieldName).ToList();
}
/// <summary>
/// 获取主键字段列表
/// </summary>
/// <returns></returns>
public List<FieldInfo> GetIdentityFields()
{
var list = Fileds.Where(x => x.IsIdentity);
if (list == null) return null;
return list.ToList();
}
/// <summary>
/// 获取可空字段。
/// </summary>
/// <returns></returns>
public List<FieldInfo> GetIsNullableFields()
{
var list = Fileds.Where(x => x.IsNullable);
if (list == null) return null;
return list.ToList();
}
/// <summary>
/// 获取不可空字段。
/// </summary>
/// <returns></returns>
public List<FieldInfo> GetNotNullableFields()
{
var list = Fileds.Where(x => !x.IsNullable);
if (list == null) return null;
return list.ToList();
}
}
}