Current filter:
                                You should refresh the page.
                                  •  I need to map the existing db structure as an aggregated asociation (For me Object Class A with both tables properties), so the problems I'm

                                    [C#]
                                    public partial class ClassA { ....... ClassAExt fAExt; [Aggregated] public ClassAExt OtherProps { get { if (KEYNAME_ONE == null) { return new ClassAExt(Session); } else { if (fAExt== null) { fAExt= Session.GetObjectByKey<ClassAExt>(KEYNAME_ONE); return fPersonalDetails; } else { return fAExt; } } } }

                                    So my questions begin;

                                    1 - Any better aproach? (I know improving db design would be the best but not an option for me)

                                    2 - This works on read and update but on creating need to save the ClassAExt record after I have the ClassA key value: what is the correct way to achieve this?

                                    Thanks in advance

                                • Gosha (DevExpress Support) 08.02.2019

                                  Hi,

                                  XPO can't map persistent classes to this inheritance in SQL objects automatically. It's necessary to create two persistent classes for each table and manually synchronize their CRUD operations. So, your approach is correct.

                                • Raúl Samper 08.02.2019

                                  Thank you very much.

                                  So, replacing save method in ClassA to call base.save() and then fAExt.save() setting before the key would do it and its the way to go?

                                • Uriah (DevExpress Support) 08.05.2019

                                  Hello,

                                  This approach will not work with Unit of Works, because the object identifier will not be available until the UnitOfWork.CommitChanges method is called.

                                  A possible way to overcome this is to disable the auto-generation of identity values at the database level and generate them programmatically (How to make user-friendly object identifiers). In this case, you will be able to automatically create a new ClassAExt instance in the overridden AfterConstruction method.

                                  We need additional time to discuss your scenario. Please bear with us. We will get back to you as soon as possible.

                                1 Solution

                                Creation Date Importance Sort by

                                Hello,

                                Thank you for your patience.

                                I need to map the existing db structure as an aggregated asociation (For me Object Class A with both tables properties)

                                You can achieve this result using Inheritance Mapping. When each class is mapped to own table, XPO synchronizes keys when saving a new object.

                                public abstract class ClassA :XPLiteObject {
                                    ...
                                }
                                
                                [MapInheritance(MapInheritanceType.OwnTable)]
                                public class ClassAExt :ClassA {
                                    ...
                                }

                                Inheritance Mapping requires the following auxiliary database objects:

                                • The 'XPObjectType' table with the TypeName and AssemblyName columns
                                • The 'ObjectType' column in the 'ClassA' table with a foreign key constraint referencing the XPObjectType table
                                [SQL]
                                if not exists (select * from sysobjects where [name] = 'XPObjectType' and xtype = 'U') begin create table XPObjectType( OID int identity(1,1) not for replication not null, TypeName nvarchar(254) null, AssemblyName nvarchar(254) null, constraint PK_XPObjectType primary key clustered (OID asc) ); alter table TableA add ObjectType int null; alter table TableA add constraint FK_TableA_ObjectType foreign key (ObjectType) references XPObjectType (OID); end;

                                Please try this solution and let me know if it meets your requirements.

                                • Raúl Samper 08.11.2019

                                  Thanks Uriah!
                                  this seems to me the way to go.

                                  It makes sense. (Other questions then comes to me but that would be subject for other ticket(s))

                                  Really apreciate your help.

                                • Uriah (DevExpress Support) 08.11.2019

                                  You are welcome, Raúl!