增加视图模板
continuous-integration/drone/push Build is passing

This commit is contained in:
2024-09-05 18:05:26 +08:00
parent 6fd239cf70
commit 753941204f
5 changed files with 81 additions and 35 deletions
+38 -3
View File
@@ -1,7 +1,6 @@
using Fluid;
using IRaCIS.Core.Infra.EFCore;
using IRaCIS.Core.Test.Template;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Options;
using System;
@@ -48,6 +47,7 @@ partial class Program
#endregion
#region
@@ -68,11 +68,11 @@ partial class Program
string dataType = property.ClrType.Name;
bool isNullable = property.IsNullable;
Console.WriteLine($" Column: {columnName}, Data Type: {dataType}, Is Nullable: {isNullable}");
}
}
#endregion
#endregion
// 要生成的表名数组
var tableNames = new List<string> { "Product"/*, "Order"*/ };
@@ -154,4 +154,39 @@ partial class Program
public DateTime DateTimeNow = DateTime.Now;
}
#region code first
public void CheckCodeFirst()
{
var contextOptions = new DbContextOptionsBuilder<IRaCISDBContext>().UseSqlServer(@"Server=106.14.89.110,1435;Database=Test_IRC;User ID=sa;Password=xc@123456;TrustServerCertificate=true").Options;
using var dbContext = new IRaCISDBContext(contextOptions);
var dbModel = dbContext.Model;
foreach (var entityType in dbModel.GetEntityTypes())
{
string tableName = entityType.GetTableName();
Console.WriteLine($"Table: {tableName}");
foreach (var property in entityType.GetProperties())
{
string columnName = property.GetColumnName();
string dataType = property.ClrType.Name;
bool isNullable = property.IsNullable;
int? maxLength = property.GetMaxLength(); // 获取最大长度
string columnType = property.GetColumnType(); // 获取数据库中的列类型
bool isKey = property.IsKey(); // 判断是否为主键
bool isIndex = property.IsIndex(); // 判断是否是索引
object defaultValue = property.GetDefaultValue(); // 获取默认值
bool isGenerated = property.ValueGenerated != Microsoft.EntityFrameworkCore.Metadata.ValueGenerated.Never; // 判断是否是自动生成的值
Console.WriteLine($" Column: {columnName}, Data Type: {dataType}, Is Nullable: {isNullable}, Max Length: {maxLength}, Column Type: {columnType}, Is Key: {isKey}, Is Index: {isIndex}, Default Value: {defaultValue}, Is Generated: {isGenerated}");
}
}
}
#endregion
}