ow
This commit is contained in:
commit
5959bae57b
56 files changed
+5152
No files matched your search
@@ -0,0 +1,39 @@
|
||||
using CloudBuilder.Core.DependencyInjection.EFCore;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CloudBuilder.CodeGenerator.Entity
|
||||
{
|
||||
public partial class CodeGeneratorRegistEntity : IMasterRegistEntityType<ModelBuilder>
|
||||
{
|
||||
/// <summary>
|
||||
/// 注入模块内的所有实体类
|
||||
/// </summary>
|
||||
/// <param name="builder"></param>
|
||||
public void RegistEntity(ModelBuilder builder)
|
||||
{
|
||||
string _assemblyName = Assembly.GetExecutingAssembly().GetName().Name;
|
||||
//注入所有Entity实体类
|
||||
AddEntityType(builder, _assemblyName);
|
||||
//如果Entity实体类不是单一主键,要单独重写注入
|
||||
RegistKeys(builder);
|
||||
}
|
||||
|
||||
public void AddEntityType(ModelBuilder builder, string _assemblyName)
|
||||
{
|
||||
RegistEntityHelper.AddMasterEntityType(builder, _assemblyName);
|
||||
}
|
||||
|
||||
public void RegistKeys(ModelBuilder builder)
|
||||
{
|
||||
//***BEGIN***
|
||||
builder.Entity<SysTableSchemaViewEntity>(eb => { eb.HasNoKey(); });
|
||||
//***END***
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,134 @@
|
||||
using CloudBuilder.Core.DatabaseAccessor.Entity;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace CloudBuilder.CodeGenerator.Entity
|
||||
{
|
||||
[Table("sys_table_schema_view")]
|
||||
public class SysTableSchemaViewEntity : ViewEntityBase
|
||||
{
|
||||
[Column("table_name")]
|
||||
public string TableName { get; set; }
|
||||
[Column("field_name")]
|
||||
public string FieldName { get; set; }
|
||||
[Column("type_name")]
|
||||
public string TypeName { get; set; }
|
||||
[Column("type_of_name")]
|
||||
public string TypeOfName { get; set; }
|
||||
[Column("max_length")]
|
||||
public int MaxLength { get; set; }
|
||||
[Column("scale")]
|
||||
public int Scale { get; set; }
|
||||
[Column("is_null_able")]
|
||||
public string IsNullAble { get; set; }
|
||||
[Column("field_default_value")]
|
||||
public string FieldDefaultValue { get; set; }
|
||||
[Column("xtype")]
|
||||
public string Xtype { get; set; }
|
||||
[Column("find_by")]
|
||||
public int FindBy { get; set; }
|
||||
[Column("operation")]
|
||||
public int Operation { get; set; }
|
||||
[Column("pk")]
|
||||
public int Pk { get; set; }
|
||||
[Column("pk_name")]
|
||||
public string PkName { get; set; }
|
||||
[Column("is_identity")]
|
||||
public int IsIdentity { get; set; }
|
||||
[Column("colid")]
|
||||
public int Colid { get; set; }
|
||||
|
||||
|
||||
public const string TABLE_NAME = "TableName";
|
||||
public const string FIELD_NAME = "FieldName";
|
||||
public const string TYPE_NAME = "TypeName";
|
||||
public const string TYPE_OF_NAME = "TypeOfName";
|
||||
public const string MAX_LENGTH = "MaxLength";
|
||||
public const string SCALE = "Scale";
|
||||
public const string IS_NULL_ABLE = "IsNullAble";
|
||||
public const string FIELD_DEFAULT_VALUE = "FieldDefaultValue";
|
||||
public const string XTYPE = "Xtype";
|
||||
public const string FIND_BY = "FindBy";
|
||||
public const string OPERATION = "operation";
|
||||
public const string PK = "Pk";
|
||||
public const string PK_NAME = "PkName";
|
||||
public const string IS_IDENTITY = "IsIdentity";
|
||||
public const string COLID = "Colid";
|
||||
|
||||
public const string DB_NAME_SYS_TABLE_SCHEMA = "sys_table_schema_view";
|
||||
|
||||
public const string DB_NAME_FIELDS = "table_name,field_name,type_name,type_of_name,max_length,scale,is_null_able,field_default_value,xtype,find_by,operation,pk,pk_name,is_identity,colid";
|
||||
|
||||
public const string DB_TABLE_NAME = "table_name";
|
||||
public const string DB_FIELD_NAME = "field_name";
|
||||
public const string DB_TYPE_NAME = "type_name";
|
||||
public const string DB_TYPE_OF_NAME = "type_of_name";
|
||||
public const string DB_MAX_LENGTH = "max_length";
|
||||
public const string DB_SCALE = "scale";
|
||||
public const string DB_IS_NULL_ABLE = "is_null_able";
|
||||
public const string DB_FIELD_DEFAULT_VALUE = "field_default_value";
|
||||
public const string DB_XTYPE = "xtype";
|
||||
public const string DB_FIND_BY = "find_by";
|
||||
public const string DB_OPERATION = "operation";
|
||||
public const string DB_PK = "pk";
|
||||
public const string DB_PK_NAME = "pk_name";
|
||||
public const string DB_IS_IDENTITY = "is_identity";
|
||||
public const string DB_COLID = "colid";
|
||||
|
||||
|
||||
public static SysTableSchemaViewEntity GetInstance()
|
||||
{
|
||||
return new SysTableSchemaViewEntity();
|
||||
}
|
||||
|
||||
public SysTableSchemaViewEntity()
|
||||
: base()
|
||||
{
|
||||
}
|
||||
|
||||
public virtual void CopyFrom(SysTableSchemaViewEntity source)
|
||||
{
|
||||
CopyFrom(source, true);
|
||||
}
|
||||
|
||||
public virtual void CopyFrom(SysTableSchemaViewEntity source, bool includeSystemFields)
|
||||
{
|
||||
if (source == null)
|
||||
{
|
||||
throw new NullReferenceException("Source entity is null.");
|
||||
}
|
||||
|
||||
this.TableName = source.TableName;
|
||||
this.FieldName = source.FieldName;
|
||||
this.TypeName = source.TypeName;
|
||||
this.TypeOfName = source.TypeOfName;
|
||||
this.MaxLength = source.MaxLength;
|
||||
this.Scale = source.Scale;
|
||||
this.IsNullAble = source.IsNullAble;
|
||||
this.FieldDefaultValue = source.FieldDefaultValue;
|
||||
this.Xtype = source.Xtype;
|
||||
this.FindBy = source.FindBy;
|
||||
this.Operation = source.Operation;
|
||||
this.Pk = source.Pk;
|
||||
this.PkName = source.PkName;
|
||||
this.IsIdentity = source.IsIdentity;
|
||||
this.Colid = source.Colid;
|
||||
|
||||
if (includeSystemFields)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public string GetSelectFrom()
|
||||
{
|
||||
return $" select {DB_NAME_FIELDS} from {DB_NAME_SYS_TABLE_SCHEMA} ";
|
||||
}
|
||||
|
||||
public SysTableSchemaViewEntity Clone()
|
||||
{
|
||||
SysTableSchemaViewEntity result = new SysTableSchemaViewEntity();
|
||||
result.CopyFrom(this);
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user