First, we will have to retrieve the ‘user’ object we want to delete, and then add this deletion operation in the queue by ‘Delete On Submit’ method.Finally commit the operation using ‘Submit Changes’ method as before; Just like insert operation, this delete operation example given above will work for .
In order to perform an update operation with Linq2Sql classes you need to keep your context alive.
In the example you have above, you include your selection inside a using statement, so your records are returned and then the context is dumped.
This way you can have a variety of ways that your object is created and the method is only responsible for the persistance of that object not also it's creation and populating.
A couple of problems I see in your approach: // a method higher up the chain void Create Customer Log() void Update Customer Log(string application No) Data_Customer_Log Get Customer Log(string application No) Data_Customer_Log Insert Or Update(Data_Customer_Log record) Data_Customer_Log Insert(Data_Customer_Log record) Data_Customer_Log Update(Data_Customer_Log record) I would probably point out that these methods would probably be in different classes.
For more information, see Responsibilities of the Developer In Overriding Default Behavior.
Developers using Visual Studio can use the Object Relational Designer to develop stored procedures for this purpose.
operations in LINQ to SQL by adding, changing, and removing objects in your object model.
By default, LINQ to SQL translates your actions to SQL and submits the changes to the database.
When you go to make the update, there is a fresh context, so there is no change registered to the objects.
A way to do this could be to make the context a more global object or to pass it as a parameter.
Obviously this means you would never be able to explicitly null a nullable field.