Click here to Skip to main content
15,510,281 members
Home / Discussions / Design and Architecture
   

Design and Architecture

 
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 
AnswerRe: cross compiling a huge codebase from Power++ to c# Pin
Dave Kreskowiak8-Jul-21 12:43
mveDave Kreskowiak8-Jul-21 12:43 
AnswerRe: cross compiling a huge codebase from Power++ to c# Pin
Mycroft Holmes8-Jul-21 13:55
professionalMycroft Holmes8-Jul-21 13:55 
AnswerRe: cross compiling a huge codebase from Power++ to c# Pin
Gerry Schmitz9-Jul-21 6:47
mveGerry Schmitz9-Jul-21 6:47 
GeneralRe: cross compiling a huge codebase from Power++ to c# Pin
Mycroft Holmes9-Jul-21 13:36
professionalMycroft Holmes9-Jul-21 13:36 
GeneralRe: cross compiling a huge codebase from Power++ to c# Pin
Gerry Schmitz12-Jul-21 9:27
mveGerry Schmitz12-Jul-21 9:27 
AnswerRe: cross compiling a huge codebase from Power++ to c# Pin
jschell17-Jul-21 11:55
jschell17-Jul-21 11:55 
QuestionEasiest Way To Implement Predictive Search On An Intranet Site Pin
Maria Delpiano17-Jun-21 6:25
Maria Delpiano17-Jun-21 6:25 
AnswerRe: Easiest Way To Implement Predictive Search On An Intranet Site Pin
jschell7-Jul-21 7:43
jschell7-Jul-21 7:43 
GeneralRe: Easiest Way To Implement Predictive Search On An Intranet Site Pin
Mycroft Holmes7-Jul-21 14:28
professionalMycroft Holmes7-Jul-21 14:28 
GeneralRe: Easiest Way To Implement Predictive Search On An Intranet Site Pin
User 1407655213-Jul-21 10:23
User 1407655213-Jul-21 10:23 
QuestionSoftware architecture pattern Pin
Tabah Baridule10-Jun-21 10:32
Tabah Baridule10-Jun-21 10:32 

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.