Base solution for your next web application
Open Closed

Ability to update State of entity with batch updates #2764


User avatar
0
bilalhaidar created

Hi, I would like to be able in my Domain Manager to update the State of objects to Deleted, Added, Updated, etc. Then in one single method do a batch SaveChanges() instead of having to update one object at a time.

While using IRepository<T> I couldn't see a place where I can access the Context or be able to change state of entities. How is this doable with this framework?

Thanks


6 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    ABP or AspNet Zero does not support batch operations. You can create a custom repository, see <a class="postlink" href="http://aspnetboilerplate.com/Pages/Documents/Repositories#custom-repositories">http://aspnetboilerplate.com/Pages/Docu ... positories</a> and access dbcontext in it.

  • User Avatar
    0
    bilalhaidar created

    How would you do batch? If you needed to have this feature, shall I go by custom repository?

    Thanks

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    Actually it depends on how much record are you going to operate on. If it is too much, I would use SQL query, if it is just a few records I would use classic repositories.

  • User Avatar
    0
    bilalhaidar created

    So, it is fine like to update record by record for few records? (10 or so?)

    SQL is an option, I could write an update for each record and send them in one shot.

  • User Avatar
    0
    bilalhaidar created

    Have a look at this library: <a class="postlink" href="https://github.com/zzzprojects/EntityFramework-Plus">https://github.com/zzzprojects/EntityFramework-Plus</a>

    Seems this allows batch update or create. Looks interesting.

  • User Avatar
    0
    ismcagdas created
    Support Team

    Thanks,

    I have seen it but we didn't try it with ABP or AspNet Zero before. I will try it if I have free time.