linq2db: [linq2db.Access] DC.update(object) doesn't update pointer to related tables
hello!
There’s no exception but during a simple update, the foreign key field is not updated. Here’s the code:
Dim myPrj As PrjMain
myPrj = DM.PrjMains.getByID(DC, myID).FirstOrDefault
myPrj.Title = tbxTitle.Text.Trim
myPrj.FkIDCompany = CType(ddlCustomer.SelectedValue, Integer) 'this one is not updated
myPrj.FkIDCompanyBroker = CType(ddlBroker.SelectedValue, Integer) 'this one is OK!!!!
myPrj.FkIDPrjType = CType(ddlProjectType.SelectedValue, Integer)
myPrj.FkUserNameConsultant = ddlConsulente.SelectedValue
DC.Update(myPrj)
Here is model extract:
[Table("PRJ-Main")]
public partial class PrjMain
{
[Column(), PrimaryKey, Identity] public int ID { get; set; } // Long
[Column("title"), Nullable ] public string Title { get; set; } // VarChar(255)
/// <summary>
/// Cliente
/// </summary>
[Column("FK_IDCompany"), Identity] public int FkIDCompany { get; set; } // Long
/// <summary>
/// Segnalatore
/// </summary>
[Column("FK_IDCompanyBroker"), Nullable ] public int? FkIDCompanyBroker { get; set; } // Long
/// <summary>
/// Importo da riconoscere al segnalatore
/// </summary>
[Column("amountFeeBroker"), Nullable ] public decimal? AmountFeeBroker { get; set; } // Currency
/// <summary>
/// Link a tabella dei tipi di progetto
/// </summary>
[Column("FK_IDPrjType"), Identity] public int FkIDPrjType { get; set; } // Long
/// <summary>
/// Consulente
/// </summary>
[Column("FK_UserNameConsultant"), NotNull ] public string FkUserNameConsultant { get; set; } // VarChar(50)
/// <summary>
/// Data inserimento a sistema
/// </summary>
FkIDCompany is not updated when FK_IDCompanyBroker is correctly done.
The difference is that FkIDCompany
is mandatory (type integer) instead of FK_IDCompanyBroker
(type nullable(of integer))
If I change FkIDCompany as not mandatory (nullable(of integer)) all work good!
is there a problem?
Thank you!
Environment details
linq2db version: 3.4.2
Database Server: MS Access
Database Provider:
Operating system: Windows 10
.NET Framework: 4.7.2
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 36 (18 by maintainers)
Yep