屠宰场客户端
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.

49 lines
1022 B

using Forks.EnterpriseServices.DomainObjects2;
using Forks.Utils;
using Forks.Utils.Data;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
namespace ButcherManage.BO.Utils
{
public static class DbUtil
{
public static void UpdateDatabase(string sqlConnection)
{
using (ISqlUtil sqlUtil = new SqlUtil(sqlConnection))
{
var boTypes = GetTypes();
Dmo.UpdateTables(sqlUtil, boTypes);
}
}
static IEnumerable<Type> GetTypes()
{
var asm = Assembly.GetExecutingAssembly();
foreach (var t in asm.GetExportedTypes())
{
if (t.IsAbstract)
{
continue;
}
if (t.IsClass && IsMapTable(t))
{
yield return t;
}
}
}
static bool IsMapTable(Type t)
{
var attr = ReflectionUtil.GetAttribute<MapToTableAttribute>(t);
if (attr == null)
{
return false;
}
return true;
}
}
}