question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[linq2db.Access] DC.update(object) doesn't update pointer to related tables

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:36 (18 by maintainers)

github_iconTop GitHub Comments

1reaction
MaceWinducommented, Aug 3, 2021

Yep

0reactions
MaceWinducommented, May 2, 2022

two providers mode for access implemented in https://www.nuget.org/packages/linq2db.cli

Read more comments on GitHub >

github_iconTop Results From Across the Web

Project on update/create (set values from another object en ...
What I am trying to achieve is basically expression-based two-way mapping between an entity class and a DTO, kinda like AutoMapper's projection ...
Read more >
Unable to update or delete data in a linked table
Workaround. To work around this problem, import the text file to the Access database and then run the update query or run the...
Read more >
W3layouts cms exploit
For example, you can write code to change the value of a pointer. write code ... desired Access to XMLHttpRequest on data tables...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found