AutoCrud AutoGen Optimistic Concurrency

Hi all,

I am using AutoCrud with AutoGenerated Services from my Postgresql. How can I implement the Optimistic Concurrency check for AutoGenerated Services without manually creating the DTOs.

We tried to add a column through TypeFilter option but could not make it work.


Optimistic Concurrency in AutoQuery CRUD require a ulong RowVersion property on the Request DTO so it’s better to use a ServiceFilter, e.g:

Plugins.Add(new AutoQueryFeature {
    MaxLimit = 1000,
    GenerateCrudServices = new GenerateCrudServices {
        // Comment below to disable auto-generation of missing AutoQuery Services
        AutoRegister = true,
        ServiceFilter = (op,req) => {
            if (op.Request.Properties.All(x => x.Name != "RowVersion"))
                op.Request.Properties.Add(new MetadataPropertyType {
                    Name = "RowVersion",
                    Type = "UInt64",
                    TypeNamespace = "System",
                    DataMember = new MetadataDataMember {
                        Order = op.Request.Properties.Max(x => x.DataMember?.Order ?? 0) + 1 

But you’ll want to modify it so it only adds the property to the Request DTOs where you want it enabled.

1 Like

Thank you so much, It’s working.

1 Like