Forums
New posts
Search forums
What's new
New posts
New profile posts
Latest activity
Members
Current visitors
New profile posts
Search profile posts
C# Community
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Database
LINQ
Converting from noob sql to Linq
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="Herman, post: 168965, member: 36501"] Also for the looping, if you expect to have only one result from the select part of the query, it really doesn't matter. If there is more than one however they will all be processed. If you only want to apply the change to the first record you find no matter how many you find do something like this: [xcode=vb]Public Function UpdateRepair(SerialNumber As String, EndTime As DateTime, Status As String, CSRQuoteFlag As Integer) As Integer Using db As New ProductionDataModelDataContext Dim result = db.Repairs.Where(Function(r) r.SerialNumber = SerialNumber).FirstOrDefault If Not result Is Nothing Then result.Status = Status result.CSRQuoteFlag = CSRQuoteFlag result.EndTime = EndTime.Date End If Dim changes = db.GetChangeSet db.SubmitChanges() Return changes.Updates.Count End Using End Function[/xcode] You could also use the ExecuteCommand method. If there is only one record to update anyways it won't really make a difference in speed. It might make a difference in code size however. [/QUOTE]
Insert quotes…
Verification
Post reply
Database
LINQ
Converting from noob sql to Linq
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.
Accept
Learn more…
Top
Bottom