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.

SkipValuesOnUpdate/Insert at class level

See original GitHub issue

Would it be possible to apply the SkipValuesOnUpdate and SkipValuesOnUpdate attribute at class level? Currently it is only effective at member level, but when applying a path-based Column attribute on a complex member, SkipValuesOnUpdate cannot be applied.

For example, if I supply only the customer name and not surname, I want to skip the surname field being updated to a null in the below model:

[Table("tbl_customer")]
[Column("customer_name", "Customer.Name"), SkipValuesOnUpdate(null) <-- cannot be applied 
[Column("customer_surname", "Customer.Surname"), SkipValuesOnUpdate(null) <-- cannot be applied here]
public class SomeModel
{
   ...
   [NotColumn, SkipValuesOnUpdate(null) <-- has no effect here]
   public CustomerModel Customer { get; set; }
}

this is based off the example here -> https://github.com/linq2db/linq2db/blob/master/Tests/Model/ComplexPerson.cs

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
sdanylivcommented, Jun 3, 2020

Great, it is much better than extending API.

0reactions
Quentinbcommented, Jun 3, 2020

I’ve spent some time on getting this to work and going through the code and have managed to get it to work without needing to change any code in Linq2DB itself.

The quick fix is to apply the SkipValuesOnUpdate on the actual sub-class members. i.e:

[Table("tbl_customer")]
[Column("customer_name"   , "Customer.Name")]
[Column("customer_surname", "Customer.Surname")]
public class SomeModel
{
   [NotColumn]
   public CustomerModel Customer { get; set; }
}

public CustomerModel
{
   [SkipValuesOnUpdate(null)]
   public string Name { get; set; }

   [SkipValuesOnUpdate(null)]
   public string Surname { get; set; }
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Skip a column on INSERT with JPA - java
I have a JPA/EclipseLink model with multiple parameters whose values are set as defaults by the PostgreSQL database. Specifically, I have:.
Read more >
SQL | INSERT IGNORE Statement
Inserting multiple records​​ INSERT OR IGNORE INTO Employee (EmployeeID, Name, City) VALUES (15007, 'Shikha', 'Delhi'), (15002, 'Ram', 'Mumbai'), ...
Read more >
Skip Lists
With some very small probability, - the skip list will just be a linked list, or - the skip list will have every...
Read more >
Skip list in Data structure
The skip list is an extended version of the linked list. It allows the user to search, remove, and insert the element very...
Read more >
Documentation: 15: INSERT
INSERT inserts new rows into a table. One can insert one or more rows specified by value expressions, or zero or more rows...
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