I have a form field not filling in with locode

I have a field on one of my classes that is not showing the data from the column when editing using locode. It is a string property and if I fill the text box with the data from the column it saves fine.

Version is 6.3.1

	[Alias("MFGQty")] 
[Schema("dbo")]
[NamedConnection("SPFMOnlineOrders")]
[EmitCSharp("[PropertyChanged.AddINotifyPropertyChangedInterface]")]
[EmitCSharp("[Validar.InjectValidation]")]
[System.ComponentModel.Description("MFGQty")] 
[DataContract]
public class MFGQty
{
	[DataMember(Order=1)]
	[Display(AutoGenerateField = true, AutoGenerateFilter = false, ShortName= "GTIN", Order=1)]
	public string GTIN { get; set;}
	
	[DataMember(Order=2)]
	[Display(AutoGenerateField = true, AutoGenerateFilter = false, ShortName= "Qty", Order=2)]
	public int Qty { get; set;}
	
	[DataMember(Order=3)]
	[Display(AutoGenerateField = true, AutoGenerateFilter = false, ShortName= "CreatedAt", Order=3)]
	public DateTime CreatedAt { get; set;}
	
	[DataMember(Order=4)]
	[Display(AutoGenerateField = true, AutoGenerateFilter = false, ShortName= "UpdatedAt", Order=4)]
	public DateTime? UpdatedAt { get; set;}

    [DataMember(Order = 5)]
    [Display(AutoGenerateField = true, AutoGenerateFilter = false, ShortName = "UpdatedAt", Order = 4)]
	[AutoIncrement]
    public int Id { get; set; }
}


[Route("/mfgqties/{Id}", "GET")]
[Route("/mfgqties", "GET")]
[DataContract]
public class QueryMFGQties : QueryDb<MFGQty>, IReturn<QueryResponse<MFGQty>>, IGet
{
	[DataMember(Order=1)]
	public int? Id { get; set;}
	
}
[Route("/mfgqties/{Id}", "GET")]
[DataContract]
public class DeleteMFGQty : IReturn<IdResponse>, IDelete, IDeleteDb<MFGQty>
{
	[DataMember(Order=1)]
    public int Id { get; set; }

}
[Route("/mfgqties", "POST")]
[DataContract]
public class CreateMFGQty : IReturn<IdResponse>, IPost, ICreateDb<MFGQty>
{
	[DataMember(Order=1)]
	public string GTIN { get; set;}
	
	[DataMember(Order=2)]
	public int Qty { get; set;}
	
	[DataMember(Order=3)]
	public DateTime CreatedAt { get; set;}
	
	[DataMember(Order=4)]
	public DateTime? UpdatedAt { get; set;}
	
}
[Route("/mfgqties/{Id}", "PUT")]
[DataContract]
public class UpdateMFGQty : IReturn<IdResponse>, IPut, IUpdateDb<MFGQty>
{
	[DataMember(Order=1)]
	public string GTIN { get; set;}
	
	[DataMember(Order=2)]
	public int Qty { get; set;}
	
	[DataMember(Order=3)]
	public DateTime CreatedAt { get; set;}
	
	[DataMember(Order=4)]
	public DateTime? UpdatedAt { get; set;}

    [DataMember(Order = 5)]
    public int Id { get; set; }

}

Because the database is rather large I am using AutoRegister = false and I have a file in the Types folder of the ServiceModel project. Seems that this is related to this particular object as I don’t have this on other objects.

I am including the ddl for the table as well.

/****** Object: Table [dbo].[MFGQty] Script Date: 10/3/2022 3:29:50 PM ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[MFGQty](
[GTIN] varchar NOT NULL,
[Qty] [int] NOT NULL,
[CreatedAt] [datetime] NOT NULL,
[UpdatedAt] [datetime] NULL,
[Id] [int] IDENTITY(1,1) NOT NULL,
CONSTRAINT [PK_MFGQty_1] PRIMARY KEY CLUSTERED
(
[Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO

ALTER TABLE [dbo].[MFGQty] ADD CONSTRAINT [DF_MFGQty_CreatedAt] DEFAULT (getdate()) FOR [CreatedAt]
GO

Hi @DMSpurlock,

Given the naming of the “GTIN” property, it might have something to do with the naming strategy of the OrmLite provider you have configured. Could you please also provide the code for registering the OrmLite provider from your AppHost?

You could also try using the Name property of the DataMember attribute on GTIN to confirm cause of the problem, eg

[DataMember(Order=1, Name="GTIN")]
[Display(AutoGenerateField = true, AutoGenerateFilter = false, ShortName= "GTIN", Order=1)]
public string GTIN { get; set;}

As it sounds like some kind of binding issue between OrmLite and the DB schema, but hopefully this will help us pin down the root cause of the issue you are seeing.

Let us know how you go.

Here is the code for ConfigureDb

    public void Configure(IWebHostBuilder builder) => builder
    .ConfigureServices((context, services) => {
        OrmLiteConfig.CommandTimeout = 60;
        var namedConnection = new OrmLiteConnectionFactory("myconnection inf", SqlServer2012Dialect.Provider);
        namedConnection.RegisterConnection("SPFMOnlineOrders", namedConnection);
        services.AddSingleton<IDbConnectionFactory>(namedConnection);
    })
    .ConfigureAppHost(appHost => {
        // Enable built-in Database Admin UI at /admin-ui/database
        appHost.Plugins.Add(new AdminDatabaseFeature());
    });

And I changed the DataMember attribute on the property to add Name but to no effect.

Try changing it to [DataMember(Name="Gtin")]

@DMSpurlock can reproduce this, one way to resolve this would be to use the [Alias] attribute with GTIN for your database model and keep your DTOs to use standard title case. An example here.

For your code this would be something like

[DataMember(Order=1)]
[Display(AutoGenerateField = true, AutoGenerateFilter = false, ShortName= "GTIN", Order=1)]
[Alias("GTIN")]
public string Gtin { get; set;}

Thank you both for your help. The change to lower case property name worked.
I have another question but I will ask it on another thread.

Derek