I've Dynamic dataWebsite which utilizes a SQL SP to complete update procedures..I've got a problem here, my remove functionality is another update(setting IsDeleted=1) procedures. I'm presently using LINQ query and calling datacontext.SubmitChanges() for removing. The issue is, the update LINQ query(that sets IsDeleted=1) after i call SubmitChanges() can also be calling the update SP that is intended for only Update Procedures. Can there be any choice to fire my LINQ query straight to DB rather than calling update SP?

Worker ild = (from emp in _dataContext.Worker

                                     where emp.IN_ID == int.Parse(ID)

                                     choose emp).FirstOrDefault()

ild.IsDeleted=1

_dataContext.Submitchanges()

The above mentioned code always call UpdateSP that's conigured to Update operation

Thanks ahead of time!

Regards, babu

Within this situation, would you make use of a remove saved proc that will get known as much like your update proc. The remove proc does not have to really execute a Remove FROM table query, but rather could do an Update around the underlying table setting the IsDeleted flag as appropriate:

CREATE PROCEDURE

  @Id int

AS

  UPDATE dbo.Worker

  SET IsDeleted = 1

  WHERE Id = @Id

You would map this function towards the remove behavior in LINQ to SQL just like you probably did the Update method. With this particular option, your client code would perform a simple Remove up for grabs instead of coping with the IsDeleted flag:

_dataContext.Worker.Remove(ild)

_dataContext.SubmitChanges()

Inside your model, I'd reason that you should not expose IsDeleted whatsoever. That's a database implementation detail. When utilizing soft removes, you need to abstract away your physical table and expose the functionality through sights or table value functions.

Instead of the soft remove option, you could look at together with a Tombstone table mimicing your transactional table. On the remove operation, make use of a saved proc or trigger to maneuver the record in the transactional table towards the tombstone table. With this, you can get rid of the IsDeleted flag in the database and elminate the necessity to range from the blocking on all access (including confirming).

I am not 100% certain I stick to the idea.

generally to remove the record you'd say:

_dataContext.Worker.remove(ild)

_dataContext.Submitchanges()

However it appears as if you desired to just update the record to see any Enployee which has a setting IsDeleted = 1 like a erased record. By running the code you current have you will find are generateing an UPDATE statement so the UpdateSP will fire.

It is possible to reason you cannot make use of the .remove() method and ophysically remove the entry?