Git Product home page Git Product logo

Comments (4)

FransBouma avatar FransBouma commented on September 26, 2024

Good idea! Syntax might be a bit verbose but also might be the least verbose possible.

from linqtosql2.

MikaelEliasson avatar MikaelEliasson commented on September 26, 2024

My first try was to build it with

x => x.Reads = x.Reads + 1

The problem was that Linq didn't support assignments in the inline version.

The biggest problem with that syntax is that it only allows updating a single property. If it's bound to SaveChanges it could simply allow multiple Update() to fix that. In my code the Update call triggers the Sql query. If using that approach I would either add a defered Set(propSelector, update) or create an overload for Update that can take a list of "ColumnModifications".

from linqtosql2.

FransBouma avatar FransBouma commented on September 26, 2024

It's indeed a tricky situation with which method to start the query, as you need more information appended after 'Update()' while it feels natural to start the update with 'Update()'. It is likely solvable with a myriad of lambdas but I've learned that although it works these kind of APIs aren't loved very much. Perhaps an UpdateSpecification object can be used and passed to the method? e.g.:

ctx.Customer.UpdateDirectly(c=>new UpdateSpecification() { /* init specification */});

With a specification it's possible to add whatever operations needed.

from linqtosql2.

guillaume86 avatar guillaume86 commented on September 26, 2024

CodeSmith DataContext extensions already do something like that and that's the syntax they use.

To remain consistent with SubmitChanges, I would use .SubmitUpdate(c => new UpdateSpecification() { /* init specification */});.

from linqtosql2.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.