Click here to Skip to main content
15,925,602 members
Home / Discussions / C#
   

C#

 
GeneralRe: FileSystemWatcher Problem Pin
Kevin Marois22-Feb-16 10:51
professionalKevin Marois22-Feb-16 10:51 
GeneralRe: FileSystemWatcher Problem Pin
Gerry Schmitz22-Feb-16 12:22
mveGerry Schmitz22-Feb-16 12:22 
QuestionPath.Combine ignoring first parameter of three Pin
Member 1185433519-Feb-16 3:59
Member 1185433519-Feb-16 3:59 
AnswerRe: Path.Combine ignoring first parameter of three Pin
Richard MacCutchan19-Feb-16 4:07
mveRichard MacCutchan19-Feb-16 4:07 
GeneralRe: Path.Combine ignoring first parameter of three Pin
Member 1185433519-Feb-16 4:11
Member 1185433519-Feb-16 4:11 
QuestionC# Pin
Member 1116162517-Feb-16 23:39
Member 1116162517-Feb-16 23:39 
AnswerRe: C# Pin
Richard MacCutchan17-Feb-16 23:53
mveRichard MacCutchan17-Feb-16 23:53 
AnswerRe: C# Pin
Jochen Arndt17-Feb-16 23:56
professionalJochen Arndt17-Feb-16 23:56 
AnswerRe: C# Pin
OriginalGriff17-Feb-16 23:59
mveOriginalGriff17-Feb-16 23:59 
SuggestionRe: C# Pin
Richard Deeming18-Feb-16 2:45
mveRichard Deeming18-Feb-16 2:45 
AnswerRe: C# Pin
BillWoodruff18-Feb-16 8:54
professionalBillWoodruff18-Feb-16 8:54 
GeneralRe: C# Pin
Mycroft Holmes18-Feb-16 13:18
professionalMycroft Holmes18-Feb-16 13:18 
GeneralRe: C# Pin
BillWoodruff18-Feb-16 16:13
professionalBillWoodruff18-Feb-16 16:13 
GeneralRe: C# Pin
CHill6018-Feb-16 13:30
mveCHill6018-Feb-16 13:30 
QuestionEF dynamic CRUD Pin
jackie.398117-Feb-16 3:38
jackie.398117-Feb-16 3:38 
AnswerRe: EF dynamic CRUD Pin
Dave Kreskowiak17-Feb-16 4:33
mveDave Kreskowiak17-Feb-16 4:33 
GeneralRe: EF dynamic CRUD Pin
jackie.398117-Feb-16 4:49
jackie.398117-Feb-16 4:49 
GeneralRe: EF dynamic CRUD Pin
Dave Kreskowiak17-Feb-16 5:07
mveDave Kreskowiak17-Feb-16 5:07 
GeneralRe: EF dynamic CRUD Pin
jackie.398117-Feb-16 5:22
jackie.398117-Feb-16 5:22 
GeneralRe: EF dynamic CRUD Pin
Dave Kreskowiak17-Feb-16 7:03
mveDave Kreskowiak17-Feb-16 7:03 
GeneralRe: EF dynamic CRUD Pin
jackie.398117-Feb-16 9:03
jackie.398117-Feb-16 9:03 
AnswerRe: EF dynamic CRUD Pin
Sascha Lefèvre17-Feb-16 5:36
professionalSascha Lefèvre17-Feb-16 5:36 
I'm no EF-expert but I have some experience with dynamically building query expressions. As Dave already said there's no inbuilt solution in EF for this, I'm pretty sure this would be your only alternative to constructing SQL statements:

For deletion: Build query expressions (the where-clause) dynamically using System.Linq.Expressions. Execute the query and Remove(..) the returned entities. *

For updating: Build query expressions (the where-clause) dynamically using System.Linq.Expressions. Execute the query and update the entities via Reflection. *

For adding: Create the entities via Reflection, set their properties via Reflection and Add(..) them.

For all this you would have to discover the DbSet<EntityName> -properties and Entity-types in your DbContext-class via Reflection. If the names of the properties don't exactly match those in your XML you would need to manually build a mapping dictionary.

99% sure this would work but it's a pretty big task and since (as I already saw from your last reply to Dave) you're not experienced with Reflection, I assume you would be done faster with constructing SQL statements. If you want to give this a try anyway, feel free to ask for more advice.

* Edit:
Instead of dynamically builing the query expressions you also could just "dumbly" loop over all entities in a DbSet and "scan" for those which should be deleted/updated by reading their properties with Reflection.
If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson


modified 17-Feb-16 12:05pm.

GeneralRe: EF dynamic CRUD Pin
jackie.398117-Feb-16 6:51
jackie.398117-Feb-16 6:51 
AnswerRe: EF dynamic CRUD Pin
Gerry Schmitz17-Feb-16 17:51
mveGerry Schmitz17-Feb-16 17:51 
QuestionBoss just gave me ReSharper Ultimate Pin
Ian Klek16-Feb-16 22:28
Ian Klek16-Feb-16 22:28 

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.