Home LINQ is querying a delete data
Reply: 1

LINQ is querying a delete data

Max Boy
1#
Max Boy Published in 2018-02-14 17:32:39Z

I have a simple select query in linq:

var forms = (from fc in db.formscreators
                     where fc.PropertyID == id || fc.PropertyID == 0
                     orderby fc.FormName ascending
                     select fc).ToList();

I went to MySQL Workbench and delete a data from formscreators table; however, the LINQ still returning the delete data. Why is it happening? How can I fix it?

Mrinal Kamboj
2#
Mrinal Kamboj Reply to 2018-02-15 12:40:04Z

db.formscreators what kind of source is this, I am assuming you are firing a IQueryable query and using the EF or similar DB context. Now as per my understanding of your question:

I went to MySQL Workbench and delete a data from formscreators table

This data in the formscreators is having either fc.PropertyID == id || fc.PropertyID == 0, thus you expect it not to be seen on firing the Linq query.

Can you verify ?

  • Does the database query runs an implicit transaction to ensure that DML is committed and there's no rollback or there's no FK constraint, which blocks the Record Deletion and does report an error.
  • What kind of query does IQueryable executes on the MySql, a profiler will provide more details. Since first verification of the issue would be post deletion when you run the same query on My Sql directly, then also the same data shall be seen.

For a No Sql system like Mongo, where it works on eventual consistency, it could have been the case that a stale data appears, but that cannot be the case for ACID compliant RDBMS. Mostly there's a discrepancy in your data or query, please review the cases above to ensure data / query sanctity

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.243226 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO