Current filter:
                                You should refresh the page.

                                1 Solution

                                Creation Date Importance Sort by

                                Hello, Cesar.

                                To change the key property generation method, create a custom base class for your entities and use it instead of DCBaseObject. You can specify the base class when registering an entity using the ITypesInfo.RegisterEntity(name, interfaceType, baseClass) method (see Domain Components Basics). Note that classes generated for entities initialize the key property in the AfterConstruction method using the Guid.NewGuid method if the key property is named "Oid", has the Guid type, and is not read-only, To suppress this initialization and use a custom one, implement the base class as follows:

                                [NonPersistent] public class MyDCBaseObject : XPCustomObject { public MyDCBaseObject(Session s) : base(s) { } [Key] [Persistent("Oid")] private Guid oid; [PersistentAlias("oid")] public Guid Oid { get { return oid; } } public override void AfterConstruction() { base.AfterConstruction(); oid = XpoDefault.NewGuid();// or your own key generation code } }

                                The XpoDefault.NewGuid method generates sequential Guids if the XpoDefault.GuidGenerationMode property is set to UuidCreateSequential.

                                You can specify a custom base class for all implicit many-to-many relationships in the DCIntermediateObjectSettings.BaseType property.

                                With v18.2, you can provide a custom Guid primary key generation algorithm globally with the new XpoDefault.CustomGuidGenerationHandler (XpoDefault.GuidGenerationMode = GuidGenerationMode.Custom):

                                    myCustomGuidGenerationAlgorithm = () => { return Guid.NewGuid(); };  
                                XpoDefault.CustomGuidGenerationHandler = myCustomGuidGenerationAlgorithm;  
                                Show all comments
                                • Cesar Augusto 02.19.2018

                                  Hi Michael,

                                  I found very interesting the ability to use a base class for the DCs. I will investigate it further.
                                  With this strategy, can I apply this to implicit created DCs also?

                                  About the other tip, the GuidGeneratioMode, thats the sequential ID that resets the seed after every machine reboot?

                                • Michael (DevExpress Support) 02.19.2018

                                  What do you mean by "implicit created DCs"?

                                  When the XpoDefault.GuidGenerationMode property is set to UuidCreateSequential, we use the UuidCreateSequential RPC function to generate the value. AFAIK, this generator resets the seed after a reboot.

                                • Juan Antonio Trujillo Montenegro 02.19.2018

                                  We have a base class with basically this method:

                                  private Guid NewGuid() => IsSequential ? PostgresSequenceHelper.CreateId() : XpoDefault.NewGuid();

                                  We just call it in the AfterConstruction or in the OnSaving depending on our needs.
                                  The IsSequential is just a static property same as IsXpoProfiling. Basically following this article.

                                  We also created our ConnectionProvider to use the native uuid type instead of string for the Oids.

                                • Cesar Augusto 02.19.2018

                                  Hi Michael.

                                  So, the UuidCreateSequencial in essence keeps the same problem.  The solution is the CombGuid really.

                                  About the implicit generated DCs, these are the ones that sit between a N x N relationship.

                                  In this case, I don't create an intermediary table, the framework creates it implicitely, as I can see a Table in Sql Server with Oid, GCRecord and everything. Also I noticed something like that in the paste, sniffing a colletion in TypesInfo.

                                  How can I handle the Oid in those DCs?

                                • Cesar Augusto 02.19.2018

                                  Hi Juan,

                                  I know the AfterConstruction() trick, I have already implemented that.
                                  My problem is with implicitely created DCs, the ones that sits between a N x N relationships.

                                  I don't have access to these implicit DCs, as they are not implemented by myself.

                                • Juan Antonio Trujillo Montenegro 02.19.2018

                                  Ah, I see!
                                  Unfortunately for those, we had to create our class that sits between M:N relations. Would love to see another solution for this.

                                • Michael (DevExpress Support) 02.20.2018

                                  Thank you for the clarification. You can specify a custom base class for all implicit many-to-many relationships in the DCIntermediateObjectSettings.BaseType property. Note that the DCIntermediateObject class used by default has an Int32 type key property.

                                • Cesar Augusto 02.23.2018

                                  O true, the Oid in the intermediary objects are INT, now I see it.
                                  So no need to worry myself about them (I'm not using replication anyways).


                                • Nate Laff 12.05.2018


                                  Can you share the Comb Guid generation code you're using to achieve that performance?

                                • Cesar Augusto 12.06.2018

                                  Hello Nate,
                                  its all based on

                                  The performance is all related to SQL Server just inserting a row at the end of table.