Click here to Skip to main content
15,890,123 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: Visual studio 2017 : How can i use Entity framework 6 with Database first ? Pin
Richard Deeming16-Feb-18 1:44
mveRichard Deeming16-Feb-18 1:44 
GeneralRe: Visual studio 2017 : How can i use Entity framework 6 with Database first ? Pin
Dave Kreskowiak16-Feb-18 5:09
mveDave Kreskowiak16-Feb-18 5:09 
GeneralRe: Visual studio 2017 : How can i use Entity framework 6 with Database first ? Pin
Richard Deeming16-Feb-18 5:28
mveRichard Deeming16-Feb-18 5:28 
GeneralRe: Visual studio 2017 : How can i use Entity framework 6 with Database first ? Pin
Dave Kreskowiak16-Feb-18 6:58
mveDave Kreskowiak16-Feb-18 6:58 
GeneralRe: Visual studio 2017 : How can i use Entity framework 6 with Database first ? Pin
Mycroft Holmes17-Feb-18 22:43
professionalMycroft Holmes17-Feb-18 22:43 
QuestionReplicate a form Pin
sunsher15-Feb-18 0:13
sunsher15-Feb-18 0:13 
QuestionEntity framework : Error when deleting from child entities Pin
desanti14-Feb-18 7:22
desanti14-Feb-18 7:22 
AnswerRe: Entity framework : Error when deleting from child entities Pin
Richard Deeming14-Feb-18 8:51
mveRichard Deeming14-Feb-18 8:51 
Entity Framework Gotchas – Strategies for Orphaned Child Objects[^]

When you call s.results.remove, you're clearing the parent relationship from the entity, but not marking it for deletion.

When you call context.results.remove, you're marking the entity for deletion.


NB: You can clean up your code and improve the performance by not calling ToList when you only want a single object.
VB.NET
' Loads all records into memory, selects the first one, and throws the rest away:
s = context.Students.Where(Function(t1) t1.Value > 5).ToList().First() 

' Loads only the first record into memory:
s = context.Students.Where(Function(t1) t1.Value > 5).First()

' Shorter version of the above; also loads only the first record into memory:
s = context.Students.First(Function(t1) t1.Value > 5)

You should also be aware that First will throw an exception if there are no matching records. You might want to consider using FirstOrDefault instead, which will return Nothing if there are no matching records.



"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer


GeneralRe: Entity framework : Error when deleting from child entities Pin
desanti14-Feb-18 9:43
desanti14-Feb-18 9:43 
GeneralRe: Entity framework : Error when deleting from child entities Pin
Richard Deeming14-Feb-18 9:51
mveRichard Deeming14-Feb-18 9:51 
QuestionHow can i undo all changes made to entities Pin
desanti13-Feb-18 8:45
desanti13-Feb-18 8:45 
AnswerRe: How can i undo all changes made to entities Pin
Maciej Los13-Feb-18 9:21
mveMaciej Los13-Feb-18 9:21 
AnswerRe: How can i undo all changes made to entities Pin
Mycroft Holmes13-Feb-18 13:26
professionalMycroft Holmes13-Feb-18 13:26 
AnswerRe: How can i undo all changes made to entities Pin
Dave Kreskowiak13-Feb-18 15:12
mveDave Kreskowiak13-Feb-18 15:12 
GeneralRe: How can i undo all changes made to entities Pin
desanti14-Feb-18 2:16
desanti14-Feb-18 2:16 
GeneralRe: How can i undo all changes made to entities Pin
Dave Kreskowiak14-Feb-18 2:22
mveDave Kreskowiak14-Feb-18 2:22 
GeneralRe: How can i undo all changes made to entities Pin
desanti14-Feb-18 2:41
desanti14-Feb-18 2:41 
GeneralRe: How can i undo all changes made to entities Pin
Dave Kreskowiak14-Feb-18 6:47
mveDave Kreskowiak14-Feb-18 6:47 
QuestionFont Stretch and condensed (i.e. Font Scaling) like MSword in vb6 label and textbox Pin
SNB172613-Feb-18 3:00
SNB172613-Feb-18 3:00 
AnswerRe: Font Stretch and condensed (i.e. Font Scaling) like MSword in vb6 label and textbox Pin
Tim Carmichael13-Feb-18 3:05
Tim Carmichael13-Feb-18 3:05 
GeneralRe: Font Stretch and condensed (i.e. Font Scaling) like MSword in vb6 label and textbox Pin
SNB172613-Feb-18 4:18
SNB172613-Feb-18 4:18 
GeneralRe: Font Stretch and condensed (i.e. Font Scaling) like MSword in vb6 label and textbox Pin
Tim Carmichael13-Feb-18 4:39
Tim Carmichael13-Feb-18 4:39 
Questiondtpicker field problem Pin
lazy_dude10-Feb-18 4:36
lazy_dude10-Feb-18 4:36 
AnswerRe: dtpicker field problem Pin
Richard MacCutchan10-Feb-18 5:33
mveRichard MacCutchan10-Feb-18 5:33 
GeneralRe: dtpicker field problem Pin
lazy_dude10-Feb-18 5:54
lazy_dude10-Feb-18 5:54 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.