Vous êtes sur la page 1sur 2

Q403538 - Provide some method to really update XPObjectTypes | DevExpress Support Center

25-May-15
Log In

Products

Free Trials & Demos

Buy

SUPPORT CENTER

Support
Tickets

My Account
Examples

About Us
Localization

FAQ

Submit a Support Ticket

Type search string and press Enter

solution

Training Events

Provide some method to really update XPObjectTypes

ID:
Q403538

Tags: .NET, Frameworks (XAF & XPO), eXpressApp Framework

Created O n :
5/23/2012 7:47:13 PM

Mo dified O n :
5/24/2012 6:09:03 PM

Marco 4 years ago

B u ild:
v2010 vo l 2.8 / 25-Ap r-2011

H i,

Related Questions

In our application, we had the following situation:


Classname: "Event", Tablename "InfEvent"

XPO b jecttyp e data co rru p tio n ?

This class also had a baseclass (EventBase) and as such, it's XPObjectType.Oid was used in the EventBase.ObjectType column.

Cu sto mizeTyp eIn fo fro m a n o n Xaf


Ap p licatio n

We needed to replace the Event class by a new Event class. The old 'Events' needed to be converted to new 'Events' and as such, the old one was renamed
to InfEvent (to line it up with the name of the database table).

W o rkflo w Server Missin g Sto re


In stan ce

As we knew, we had to update the XPObjectType manually but during conversion of the 'InfEvent' objects to the new 'Event' class, it appeared that XPO
tried to load InfEvent objects from the Event table (which was still empty).
After long investigation, it appears that XPO uses 2 caches for the XPObjectTypes. One of them is in the XPObjectTypesManager (_allTypes) the other one in
BaseDataLayer.StaticData.

Th e ALTER TAB LE statemen t


co n flicted w ith th e FO REIG N KEY
co n strain t ...
Ro le class ch an ge

Changing the XPObjectType record in the database does not reload these caches, so we looked at
a way to do that manually.
The XPObjectTypesManager cache can be reset by calling a DropIdentityMap.
The Static Data dictionary in BaseDataLayer however, can only be cleared by calling ClearStaticData. This method is protected and the only calling method
is ClearDatabase, something we definitely do not want.
So, in fact there is no normal way to clear this cache without clearing the database.
IMHO, when XPO notices a change in an XPObjectType object, it should have an ability to refresh it's
cache of XPObjects as well, or refresh it automatically.
Thanks,
Marco
P.S. As a workaround, we now call ClearStaticData by using reflection, but of course this is not a good solution.

Leave a Comment

1 Solution
0

Michael (DevExpress Support) 4 years ago

Hi Marco,
Thank you for the question. Your scenario is quite unusual and I am afraid we won't publish this internal method. Instead of clering this dictionary or clearing
the dataabse, I recommend that you create a new data layer after your type manipulations.
>>>IMHO, when XPO notices a change in an XPObjectType object, it should have an ability to refresh it's
cache of XPObjects as well, or refresh it automatically.
The XPObjectType class is defined as session-less and does not support change notifications. We have not considered such scenarios when designing the
XPO Library.

Marco 4 years ago


Hi Mich ael,
Allth o u gh i did n o t co n sider th is so lu tio n , it is n o t a so lu tio n in o u r scen ario . W e u se XPO w ith in XAF an d at th e p o in t w e u p date th e
XPO b jectTyp e tab le, th e cu rren t DataLayer may b e u sed already in several o th er Sessio n s / O b jectSp aces.
So recreatin g th e DataLayer is n o t a so lu tio n .
An yw ay, th an ks fo r yo u r in terest.

Michael (DevExpress Support) 4 years ago


Th an k yo u fo r men tio n in g XAF. I su ggest th at yo u refer to th e Ho w to : U p date th e Datab ase Stru ctu re after th e Persisten t Class o r Pro p erty
W as Ren amed o r Remo ved article w h ere similar tasks w ere discu ssed.
Sp ecifically, yo u can u se th e Mo du leU p dater.U p dateXPO b jectTyp e meth o d to u p date th is tab le. U n fo rtu n ately, it o n ly u p dates th e datab ase,
an d yo u n eed to man u ally relo ad ch an ged XPO b jectTyp e in stan ces. Yo u can do th is as fo llo w s:

https://www.devexpress.com/Support/Center/Question/Details/Q403538

1/2

Q403538 - Provide some method to really update XPObjectTypes | DevExpress Support Center

25-May-15

[C#]

Open in popup window


public override void UpdateDatabaseAfterUpdateSchema()
{
base.UpdateDatabaseAfterUpdateSchema();
...
_session = ((ObjectSpace)ObjectSpace).Session;
_session.CreateObjectTypeRecords(GetAssemblies());
var types = _session.TypesManager.AllTypes;
foreach (var xpObjectType in types)
{
if (!xpObjectType.Value.IsValidType)
{
_session.Reload(xpObjectType.Value);
}
}
...
}

W e w ill mo dify th e U p dateXPO b jectTyp e meth o d to au to matically relo ad XPO b jectTyp e in stan ces in th e fu tu re.
Please let me kn o w if th is h elp s.

Leave a Comment

DEVEXPRESS
About Us
News
Our Awards
Upcoming Events
User Comments
Case Studies
Reviews and Publications
Licensing
Purchasing
MVP Program
Contact Us
Logos

.NET CONTROLS
WinForms
ASP.NET
MVC
WPF
Silverlight
Windows 8 XAML
CROSS PLATFORM
Reporting
Document Automation

MOBILE
DevExtreme Mobile

HTML5 JS WIDGETS
DevExtreme Web

ENTERPRISE TOOLS
Report Server
Analytics Dashboard

iOS 7
DataExplorer

FRAMEWORKS
eXpressApp Framework
CODE-DEBUG-REFACTOR
CodeRush for Visual Studio

FUNCTIONAL WEB TESTING


TestCafe
DELPHI C++BUILDER
VCL

SUPPORT
Search the Knowledge Base
My Questions
Code Examples
Getting Started
Demos
Documentation
Blogs
Training
Webinars
Current Version/Build
Version History

FOLLOW US
If you need additional product information, write to us at info@devexpress.com or call us at +1 (818) 844-3383

DevExpress engineers feature-complete Presentation Controls, IDE Productivity Tools, Business


Application Frameworks, and Reporting Systems for Visual Studio, along with high-performance
HTML JS Mobile Frameworks for developers targeting iOS, Android and Windows Phone. Whether
using WPF, Silverlight, ASP.NET, WinForms, HTML5 or Windows 8, DevExpress tools help you
build and deliver your best in the shortest time possible.

Your Privacy - Legal Statements

https://www.devexpress.com/Support/Center/Question/Details/Q403538

Copyright 1998-2014 Developer Express Inc.


All trademarks or registered trademarks are property of their respective owners

2/2

Vous aimerez peut-être aussi