henkmollema / Dapper-FluentMap

Provides a simple API to fluently map POCO properties to database columns when using Dapper.
MIT License
427 stars 86 forks source link

Even DatabaseGeneratedOption.Computed is used for property, FluentMap.Dommel still generates column and parameter names in insert\update query #123

Closed enterpub closed 1 year ago

enterpub commented 4 years ago

.NET Core 3.1 Win 10 64 bit Dommel 2.1.0 Dapper 2.0.35 Dapper-FluentMap.Dommel 2.0.0

Even DatabaseGeneratedOption.Computed is used for property, Dapper.FluentMap.Dommel still generates column and parameter names in insert\update query, but it should skip them.

public sealed class DommelChargeMap : DommelEntityMap<ChargeDb>
    {
        public DommelChargeMap()
        {
            Map(x => x.RowVersion).SetGeneratedOption(DatabaseGeneratedOption.Computed);
        }
    }

But the insert and update has "RowVersion" and "@RowVersion" in result query.

How to archive not include such column in query?

henkmollema commented 4 years ago

Can you show the Dapper.FluentMap initialization code. Did you call ForDommel() at application startup?

You can also try to use the [DontMap] or [Ignore] attribute on the property of the ChargeDb class. This will omit the column from insert/update statements without using Dapper.FluentMap.

enterpub commented 4 years ago

Hi, I do call ForDommel()

namespace MyCustom.Data.Client.Dommel
{
    using Dapper.FluentMap;
    using Dapper.FluentMap.Dommel;
    using MyCustom.Data.Client.Dommel.EntityMaps;
    using global::Dommel;

    public sealed class DommelForClientDatabase
    {
        public static void Setup()
        {
            FluentMapper.Initialize(config =>
            {
                config.AddMap(new DommelChargeMap());
                config.ForDommel();
            });
        }
    }
}

It is being called in Startup.cs:

public void ConfigureServices(IServiceCollection services)
{
            services
                .AddControllersWithViews()
                .AddNewtonsoftJson();

           // .... other code removed for brevity

            DommelForClientDatabase.Setup();
 }
rsfurlan90 commented 3 years ago

This issue seems to be similar to #122

DanieleSky commented 2 years ago

Is this bug fixed?

enterpub commented 2 years ago

@DanieleSky , I'm afraid it is not. But I did not check

henkmollema commented 1 year ago

I'm archiving this repository as I'm not using this library myself anymore and have no time maintaining it. Thanks for using it.