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.

83 lines
3.2 KiB

1 year ago
using System.Collections.Generic;
using System.Data.Entity;
using System.Data.Entity.Migrations;
using ChangkeTec.SDMS.Model.DataCenterTables;
namespace ChangkeTec.SDMS.Model
{
public class DataCenterDatabaseInitializer : DropCreateDatabaseIfModelChanges<DataCenterContext> // DropCreateDatabaseAlways<AppBoxContext> DropCreateDatabaseIfModelChanges<AppBoxContext>
{
protected override void Seed(DataCenterContext db)
{
base.InitializeDatabase(db);
// db.TA_CONFIG.AddOrUpdate(InitConfigList);
// db.TA_MENU.AddOrUpdate(InitMenuList);
// db.TA_DEPT.AddOrUpdate(InitDeptList);
// db.TA_USER.AddOrUpdate(InitUserList);
// db.TA_USER_BUTTON.AddOrUpdate(InitUserButtonList);
// db.TA_USER_MENU.AddOrUpdate(InitUserMenuList);
// db.TA_USER_TABLE.AddOrUpdate(InitUserTableList);
// db.TA_TABLE.AddOrUpdate(InitTableList);
db.Database.ExecuteSqlCommand(ProcedureInitializer.P_GetAllTables);
db.SaveChanges();
base.Seed(db);
}
}
public static class ProcedureInitializer
{
public static string P_GetAllTables = @"
create procedure [dbo].[P_GetAllTables]
as
begin
SELECT
-- = Case When A.colorder = 1 Then D.name Else '' End,
-- = Case When A.colorder = 1 Then isnull(F.value,'') Else '' End,
= D.name,
= isnull(F.value, ''),
= A.colorder,
= A.name,
= isnull(G.[value], ''),
= Case When COLUMNPROPERTY(A.id, A.name,'IsIdentity')= 1 Then '●'Else '' End,
= Case When exists(SELECT 1 FROM sysobjects Where xtype = 'PK' and parent_obj = A.id and name in (
SELECT name FROM sysindexes WHERE indid in(SELECT indid FROM sysindexkeys WHERE id = A.id AND colid = A.colid))) then '●' else '' end,
= B.name,
= COLUMNPROPERTY(A.id, A.name, 'PRECISION'),
= isnull(COLUMNPROPERTY(A.id, A.name, 'Scale'), 0),
= Case When A.isnullable = 1 Then '●'Else '' End,
= isnull(E.Text, ''),
= A.Length
FROM
syscolumns A
Left Join
systypes B
On
A.xusertype = B.xusertype
Inner Join
sysobjects D
On
A.id = D.id and D.xtype = 'U' and D.name <> 'dtproperties'
Left Join
syscomments E
on
A.cdefault = E.id
Left Join
sys.extended_properties G
on
A.id = G.major_id and A.colid = G.minor_id
Left Join
sys.extended_properties F
On
D.id = F.major_id and F.minor_id = 0
--where d.name = 'OrderInfo'--,
Order By
D.Name,A.id,A.colorder
end
";
}
}