Ticket T189591
Visible to All Users
Duplicate

Saving model changes to the db separately for win vs web

created 10 years ago (modified 10 years ago)

I just started using the ability to store XAF application model changes in the database (using the ModelDifference class).  By default, it seems that changes made in the web version are shared with the win version (and vice versa).

I would like to have my win and web version changes to be separate.  So if a user changes some ordering of columns on the Web side, this will not affect that same ordering of columns on the Win side.

I think I've got this working but wanted to confirm with you that this is a valid solution:

  1. I subclassed the ModelDifference class with a separate class for Module.Win (ModelDifferenceWin) and Module.Web (ModelDifferenceWeb):
C#
[MapInheritance(MapInheritanceType.OwnTable)] public class ModelDifferenceWin : ModelDifference { public ModelDifferenceWin(DevExpress.Xpo.Session session) : base(session) { } }
  1. In WinModule.cs and WebModule.cs, I changed the ModelDifferenceType (below is the Win version)
C#
public TestDBModelDec19WindowsFormsModule() { InitializeComponent(); //ModelDifferenceDbStore.ModelDifferenceType = typeof(ModelDifference); ModelDifferenceDbStore.ModelDifferenceType = typeof(ModelDifferenceWin); }

ModelDifferenceDbStore.ModelDifferenceType = typeof(ModelDifferenceWin); }This seems to be working for me… the user settings changes in the Win are not affecting the Web side.  Can you see any problems with this solution?

Show previous comments (1)
Dennis Garavsky (DevExpress) 10 years ago

    Hi Richard,

    >> this resulted in a "duplicate User Id" error since the UserId field in the database is marked as unique for the table.
    I could not replicate this error at the database level, because there is currently no unique constraint for the UserId column. However, the validation error may occur at the UI level due to the validation attribute of this field. In my tests with ModelDifferenceWin/Web descendants, there was a situation when there were multiple records in the ModelDifference table with the same UserId value. You can avoid this by implementing the IModelDifference interface from scratch.
    We think that this particular scenario with different places for storing WinForms and ASP.NET settings can be implemented more easily, so you may be interested in tracking the Application Model - Make it easier to store user settings in the database for WinForms and Web applications separately request on our TODO list.

      Thanks, yes it was the Validation attribute that was reporting the error.  I'll track that new ticket as well as it looks much easier =), and for now I'll just implement the IModelDifference interface from scratch.

      Dennis Garavsky (DevExpress) 10 years ago

        Thanks for your feedback, Richard.
        Merry Christmas!

        Answers approved by DevExpress Support

        created 10 years ago (modified 10 years ago)

        Hello Richard,

        We could not find anything wrong with your solution, and you can use it in your project.
        See Also:
        Store Model Differences in DB - 14.2 - Possible to Separate Win/Web diffs?

          Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

          Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.