本文整理汇总了C#中UnitOfWork.UpdateSchema方法的典型用法代码示例。如果您正苦于以下问题:C# UnitOfWork.UpdateSchema方法的具体用法?C# UnitOfWork.UpdateSchema怎么用?C# UnitOfWork.UpdateSchema使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UnitOfWork
的用法示例。
在下文中一共展示了UnitOfWork.UpdateSchema方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateDataLayer
static IDataLayer CreateDataLayer()
{
DevExpress.Xpo.Metadata.XPDictionary dict = new DevExpress.Xpo.Metadata.ReflectionDictionary();
dict.GetDataStoreSchema(typeof(Person).Assembly);
DataSetDataStore dataStore = new DataSetDataStore(new DataSet(), AutoCreateOption.DatabaseAndSchema);
using(UnitOfWork uow = new UnitOfWork(new SimpleDataLayer(dict, dataStore))) {
uow.UpdateSchema(typeof(Person));
Person p1 = new Person(uow);
p1.FirstName = "Slava";
p1.LastName = "Donchak";
Person p2 = new Person(uow);
p2.FirstName = "Dan";
p2.LastName = "Ignatov";
Product xaf = new Product(uow);
xaf.Name = "Xaf";
xaf.Manager = p2;
Product xpo = new Product(uow);
xpo.Name = "Xpo";
xpo.Manager = p1;
uow.CommitChanges();
}
return new ThreadSafeDataLayer(dict, dataStore);
}
示例2: MergeTypes
public void MergeTypes(UnitOfWork unitOfWork, List<Type> persistentTypes, IDbCommand command)
{
var collection = new XPCollection(unitOfWork, WCTypesInfo.Instance.FindBussinessObjectType<IPersistentClassInfo>()).Cast<IPersistentClassInfo>().Where(info => info.MergedObjectFullName != null).ToList();
foreach (IPersistentClassInfo classInfo in collection){
XPClassInfo xpClassInfo = getClassInfo(classInfo.Session,classInfo.PersistentAssemblyInfo.Name+"."+ classInfo.Name,persistentTypes);
var mergedXPClassInfo = getClassInfo(classInfo.Session, classInfo.MergedObjectFullName, persistentTypes) ?? classInfo.Session.GetClassInfo(ReflectionHelper.GetType(classInfo.MergedObjectFullName));
if (xpClassInfo != null) {
unitOfWork.UpdateSchema(xpClassInfo.ClassType, mergedXPClassInfo.ClassType);
updateObjectType(unitOfWork, xpClassInfo, mergedXPClassInfo,command);
}
}
}
示例3: Setup
public override void Setup(ApplicationModulesManager moduleManager)
{
base.Setup(moduleManager);
if (Application == null)
return;
TypesInfo.Instance.AddTypes(GetAdditionalClasses());
var unitOfWork = new UnitOfWork { ConnectionString = _connectionString };
unitOfWork.UpdateSchema();
AddDynamicModules(moduleManager, unitOfWork, TypesInfo.Instance.PersistentAssemblyInfoType);
Application.SetupComplete += (sender, args) => mergeTypes(unitOfWork);
var existentTypesMemberCreator = new ExistentTypesMemberCreator();
existentTypesMemberCreator.CreateMembers(unitOfWork, TypesInfo.Instance);
}
示例4: Main
static void Main(string[] args)
{
Console.WriteLine("Creating database/deleting records...");
using(UnitOfWork uow = new UnitOfWork()) {
uow.ConnectionString = Constants.DatabaseConnectionString;
uow.UpdateSchema(typeof(Person));
foreach(Person p in new System.Collections.ArrayList(new XPCollection<Person>(uow))) {
uow.Delete(p);
}
foreach(Product p in new System.Collections.ArrayList(new XPCollection<Product>(uow))) {
uow.Delete(p);
}
uow.CommitChanges();
}
Console.WriteLine("Creating records...");
using(UnitOfWork uow = new UnitOfWork()) {
uow.ConnectionString = Constants.DatabaseConnectionString;
uow.UpdateSchema(typeof(Person));
Person p1 = new Person(uow);
p1.FirstName = "Slava";
p1.LastName = "Donchak";
Person p2 = new Person(uow);
p2.FirstName = "Dan";
p2.LastName = "Ignatov";
Product xaf = new Product(uow);
xaf.Name = "Xaf";
xaf.Manager = p2;
Product xpo = new Product(uow);
xpo.Name = "Xpo";
xpo.Manager = p1;
uow.CommitChanges();
}
Console.WriteLine("Database is recreated.");
Console.ReadLine();
}