xavehoo
/
XAF_how-to-prevent-altering-the-legacy-database-schema-when-creating-an-xaf-application-e1150
Public
forked from DevExpress-Examples/xaf-how-to-prevent-altering-the-legacy-database-schema-when-creating-an-xaf-application
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Module.cs
33 lines (32 loc) · 1.62 KB
/
Module.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
using System;
using System.Collections.Generic;
using DevExpress.ExpressApp;
using System.Reflection;
using DevExpress.ExpressApp.Xpo;
using System.Configuration;
namespace WinWebSolution.Module {
public sealed partial class WinWebSolutionModule : ModuleBase {
private static XpoDataStoreProxyProvider provider;
public WinWebSolutionModule() {
InitializeComponent();
}
public override void Setup(XafApplication application) {
base.Setup(application);
application.CustomCheckCompatibility += new EventHandler<CustomCheckCompatibilityEventArgs>(application_CustomCheckCompatibility);
application.CreateCustomObjectSpaceProvider += new EventHandler<CreateCustomObjectSpaceProviderEventArgs>(application_CreateCustomObjectSpaceProvider);
}
void application_CreateCustomObjectSpaceProvider(object sender, CreateCustomObjectSpaceProviderEventArgs e) {
if(provider == null) {
provider = new XpoDataStoreProxyProvider();
}
e.ObjectSpaceProvider = new XPObjectSpaceProvider(provider);
}
void application_CustomCheckCompatibility(object sender, CustomCheckCompatibilityEventArgs e) {
if(provider != null && !provider.IsInitialized) {
provider.Initialize(((XPObjectSpaceProvider)e.ObjectSpaceProvider).XPDictionary,
ConfigurationManager.ConnectionStrings["LegacyDatabaseConnectionString"].ConnectionString,
ConfigurationManager.ConnectionStrings["TempDatabaseConnectionString"].ConnectionString);
}
}
}
}