Click here to Skip to main content
15,560,045 members
Home / Discussions / Design and Architecture
   

Design and Architecture

 
Question[Solved] Opinions on two code layout alternatives? Pin
RobertSF10-Dec-21 11:43
professionalRobertSF10-Dec-21 11:43 
AnswerRe: Opinions on two code layout alternatives? Pin
Gerry Schmitz11-Dec-21 7:08
mveGerry Schmitz11-Dec-21 7:08 
GeneralRe: Opinions on two code layout alternatives? Pin
RobertSF11-Dec-21 8:09
professionalRobertSF11-Dec-21 8:09 
GeneralRe: Opinions on two code layout alternatives? Pin
Gerry Schmitz11-Dec-21 8:43
mveGerry Schmitz11-Dec-21 8:43 
GeneralRe: Opinions on two code layout alternatives? Pin
RobertSF11-Dec-21 12:44
professionalRobertSF11-Dec-21 12:44 
AnswerRe: Opinions on two code layout alternatives? Pin
englebart29-Dec-21 16:56
professionalenglebart29-Dec-21 16:56 
GeneralRe: Opinions on two code layout alternatives? Pin
RobertSF2-Jan-22 14:10
professionalRobertSF2-Jan-22 14:10 
QuestionDocumentation or modeling tool for a DB-application Pin
Member 1331165719-Nov-21 20:43
Member 1331165719-Nov-21 20:43 
AnswerRe: Documentation or modeling tool for a DB-application Pin
Gerry Schmitz1-Dec-21 19:29
mveGerry Schmitz1-Dec-21 19:29 
AnswerRe: Documentation or modeling tool for a DB-application Pin
Mycroft Holmes2-Dec-21 12:01
professionalMycroft Holmes2-Dec-21 12:01 
GeneralRe: Documentation or modeling tool for a DB-application Pin
Member 133116573-Dec-21 5:55
Member 133116573-Dec-21 5:55 
GeneralRe: Documentation or modeling tool for a DB-application Pin
Mycroft Holmes3-Dec-21 12:29
professionalMycroft Holmes3-Dec-21 12:29 
QuestionAsync design Pin
Mycroft Holmes10-Nov-21 12:31
professionalMycroft Holmes10-Nov-21 12:31 
AnswerRe: Async design Pin
Gerry Schmitz10-Nov-21 21:26
mveGerry Schmitz10-Nov-21 21:26 
AnswerRe: Async design Pin
Richard Deeming10-Nov-21 22:39
mveRichard Deeming10-Nov-21 22:39 
GeneralRe: Async design Pin
Mycroft Holmes11-Nov-21 13:29
professionalMycroft Holmes11-Nov-21 13:29 
AnswerRe: Async design Pin
Greg Utas11-Nov-21 3:13
mveGreg Utas11-Nov-21 3:13 
QuestionCommon Code Pin
Kevin Marois3-Nov-21 14:00
professionalKevin Marois3-Nov-21 14:00 
QuestionDAL Design Question Pin
Kevin Marois9-Aug-21 8:16
professionalKevin Marois9-Aug-21 8:16 
I'm working on a WPF app. My UI, BL, and DAL are all in one solution and each assembly is installed locally on each user's PC.

I typically have code like this in my ViewModel SaveChanges:
private void SaveChanges()
{
    foreach (var job in Jobs.Where(x => x.IsDirty).ToList())
    {
        if (job.Id == 0)
        {
            DAL.AddJob(job);
        }
        else
        {
            DAL.UpdateJob(job);
        }
    }

    foreach (var deletedId in deletedJobIds)
    {
        DAL.DeleteJob(deletedId);
    }
}
Functionally this works, but it has some underlying issues:
  1. It requires looping over each changed entity and calling either Add or Update. Then I have to call delete.
  2. At some point soon I will need to move the BL & DAL to a Web API.
So I'm considering the following change. The DAL methods would look like:
private void SaveChanges()
{
    // Make one call, passing all the data to add/change
    DAL.SaveJobs(Jobs.Where(x => x.IsDirty).ToList(), _deletedJobIs);
}
In a stateful Windows app, each entity is an object ref so I can set the newly added Id's in the DAL and it will be available back in the VM.

But if I use the single AddUpdate method in a WebAPI, how to I get back the Id's of the newly added items?

One of the primiary goals of these changes is is to reduce the amount of calls the the back end.

I'd like to hear suggestions on best preactices for this.
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.


modified 9-Aug-21 13:29pm.

AnswerRe: DAL Design Question Pin
Mycroft Holmes9-Aug-21 13:44
professionalMycroft Holmes9-Aug-21 13:44 
AnswerRe: DAL Design Question Pin
Eric P Schneider11-Oct-21 20:41
Eric P Schneider11-Oct-21 20:41 
QuestionWhat is an archetect? Pin
Tad McClellan6-Aug-21 18:55
professionalTad McClellan6-Aug-21 18:55 
AnswerRe: What is an archetect? Pin
Gerry Schmitz7-Aug-21 6:22
mveGerry Schmitz7-Aug-21 6:22 
AnswerRe: What is an archetect? Pin
Mycroft Holmes7-Aug-21 13:36
professionalMycroft Holmes7-Aug-21 13:36 
Questioncross compiling a huge codebase from Power++ to c# Pin
sx20088-Jul-21 12:17
sx20088-Jul-21 12:17 

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.