how entity framework working

qianli

Please refer to this picture:

this picture

This table data are fetched with Entity Framework. When I double click the EmailID and change it, the data will be updated to SQL Server automatically.

Here it's web api code about update:

// PUT: api/Subscriber/5
public void Put(tbl_Subscribers sub)
{
    if (ModelState.IsValid)
    {
        myEntity.Entry(sub).State = EntityState.Modified;
        try
        {
            myEntity.SaveChanges();
        }
        catch (Exception)
        {
            throw;
        }
    }
}

When this code run, the modified emailID has been updated to SQL Server, no need any sql state, no need ID, how it update the code?

AngularJS controller:

$scope.updSubscriber = function (sub, eve) {
    sub.MailID = eve.currentTarget.innerText;//get EmailID
    var upd = APIService.updateSubscriber(sub);//update EmailID
    upd.then(function (d) {
        getAll();
    }, function (error) {
        console.log('Oops! Something went wrong while updating the data.')
    })
};

Angular Service:

this.updateSubscriber = function (sub) {
return $http({
    method: 'put',
    data: sub,
    url: 'api/Subscriber'
});

}

Hope some one could help me explain it.

Antoine Pelletier

It looks like every row subscribe to a wep API function. The function uses Angular JS to make async call to your code behind.

Then, ain't no magic here :

    myEntity.Entry(sub).State = EntityState.Modified;
    try
    {
        myEntity.SaveChanges();
    }

Sub contain informations about what has been modified on your entity.

Once db.SaveChages() is reached, it looks for what modifications should be made in your db, there is only one at the time so it's probably very fast.

Entity Framework write it's own db query on the backend, you can't see them unless you use a profiler.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How many to many relationship in Entity Framework is working

From Dev

Entity Framework Seed not working

From Dev

entity framework insert not working

From Dev

Entity Framework ConnectionString Not Working

From Dev

How do I know that Entity Framework's Eager Loading is working?

From Dev

Entity Framework view associations not working

From Dev

AJAX Delete Not Working Entity Framework

From Dev

DataBinding() not working with Distinct() (Entity Framework)

From Dev

Entity Framework Navigation property not working

From Dev

Entity Framework and Membership Provider not working

From Dev

Entity framework - LINQ JOIN not working

From Dev

entity framework savechanges not Working MVC

From Dev

Entity DataSource not working with Entity Framework 6 Upgrade

From Dev

Entity DataSource not working with Entity Framework 6 Upgrade

From Dev

How Entity Framework works

From Dev

How to InsertOrSelect with Entity Framework

From Dev

Insert records in many to many not working with Entity Framework

From Dev

Seeding not working in Entity Framework Code First Approach

From Dev

Simple JOIN Syntax Not Working in Entity Framework

From Dev

Working with normalized data in Entity Framework 6?

From Dev

Entity Framework SQL Query not Working with SQL Parameters

From Dev

Entity Framework One To required Many mapping not working

From Dev

Update model from database in entity framework is not working

From Dev

Entity Framework - Lazy Loading working even with ToList()

From Dev

Entity Framework Db.SaveChanges() not working?

From Dev

Code First Entity Framework Lazy Loading Not Working

From Dev

Entity framework code first no errors but not working

From Dev

Entity Framework Include() is not working within complex query

From Dev

Entity Framework Migrations update metadata not working

Related Related

  1. 1

    How many to many relationship in Entity Framework is working

  2. 2

    Entity Framework Seed not working

  3. 3

    entity framework insert not working

  4. 4

    Entity Framework ConnectionString Not Working

  5. 5

    How do I know that Entity Framework's Eager Loading is working?

  6. 6

    Entity Framework view associations not working

  7. 7

    AJAX Delete Not Working Entity Framework

  8. 8

    DataBinding() not working with Distinct() (Entity Framework)

  9. 9

    Entity Framework Navigation property not working

  10. 10

    Entity Framework and Membership Provider not working

  11. 11

    Entity framework - LINQ JOIN not working

  12. 12

    entity framework savechanges not Working MVC

  13. 13

    Entity DataSource not working with Entity Framework 6 Upgrade

  14. 14

    Entity DataSource not working with Entity Framework 6 Upgrade

  15. 15

    How Entity Framework works

  16. 16

    How to InsertOrSelect with Entity Framework

  17. 17

    Insert records in many to many not working with Entity Framework

  18. 18

    Seeding not working in Entity Framework Code First Approach

  19. 19

    Simple JOIN Syntax Not Working in Entity Framework

  20. 20

    Working with normalized data in Entity Framework 6?

  21. 21

    Entity Framework SQL Query not Working with SQL Parameters

  22. 22

    Entity Framework One To required Many mapping not working

  23. 23

    Update model from database in entity framework is not working

  24. 24

    Entity Framework - Lazy Loading working even with ToList()

  25. 25

    Entity Framework Db.SaveChanges() not working?

  26. 26

    Code First Entity Framework Lazy Loading Not Working

  27. 27

    Entity framework code first no errors but not working

  28. 28

    Entity Framework Include() is not working within complex query

  29. 29

    Entity Framework Migrations update metadata not working

HotTag

Archive