Linq to sql view not updating
We will name our Visual Studio project Console LINQ2SQL and use the C# language. Click on the Project menu and select Add New Item... Create a new connection to a SQL Server database by clicking on the Connect to Database icon in the Server Explorer window.
The Add Connection window appears which will ask you to specify the SQL Server instance name, database name and your login credentials.
EDIT2: It mentions the username and Last Updated By issue here: doesn't elaborate on exactly how to deal with it other than to use the "Updating event" in the LINQ data source.
I can of course access that event, but I don't know what to do once I'm there... Linq Data Source Update Event Args) Handles lds Audit Criteria Details. Now End Sub However, I don't claim to fully understand that.
I am no LINQ expert, but I cannot imagine it is updating the data more than once (just committing changes when you call . So while you may be updating the object model representation of the data in two diffferent places, the updates get coalesced when you call Submit Changes().
Another approach, which in my opinion is more appropriate for an Auditing function, is to either let the database fill that field in with a default value (i.e.
MSDN talks about how to handle NULL fields and provide them with a default value, but I basically need to just overwrite whatever is in Last Updated and Last Updated By with the current system datetime and the current user.
Protected Sub lds Audit Criteria Details_Updating(By Val sender As Object, By Val e As System. It stores criteria for audits (crazy cool I know)So what exactly was I doing when I said What EXACTLY is that doing?There are several other methods that you can utilize as well.The On Validate is great because you can do validation at the object level instead of the client side.I have a drop down list that selects the Audit Name and then the detail view shows all the details of that audit.but that's another battle for another day I suppose. Other than I suppose writing some code to do something weird like wipe out the entire list of items in the DDL and then readd them or something twisted.