Click here to Skip to main content
15,880,608 members
Home / Discussions / Design and Architecture
   

Design and Architecture

 
GeneralRe: Documentation or modeling tool for a DB-application Pin
Mycroft Holmes3-Dec-21 11:29
professionalMycroft Holmes3-Dec-21 11:29 
QuestionAsync design Pin
Mycroft Holmes10-Nov-21 11:31
professionalMycroft Holmes10-Nov-21 11:31 
AnswerRe: Async design Pin
Gerry Schmitz10-Nov-21 20:26
mveGerry Schmitz10-Nov-21 20:26 
AnswerRe: Async design Pin
Richard Deeming10-Nov-21 21:39
mveRichard Deeming10-Nov-21 21:39 
GeneralRe: Async design Pin
Mycroft Holmes11-Nov-21 12:29
professionalMycroft Holmes11-Nov-21 12:29 
AnswerRe: Async design Pin
Greg Utas11-Nov-21 2:13
professionalGreg Utas11-Nov-21 2:13 
QuestionCommon Code Pin
Kevin Marois3-Nov-21 13:00
professionalKevin Marois3-Nov-21 13:00 
QuestionDAL Design Question Pin
Kevin Marois9-Aug-21 7:16
professionalKevin Marois9-Aug-21 7: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 12:44
professionalMycroft Holmes9-Aug-21 12:44 
AnswerRe: DAL Design Question Pin
Eric P Schneider11-Oct-21 19:41
Eric P Schneider11-Oct-21 19:41 
QuestionWhat is an archetect? Pin
Tad McClellan6-Aug-21 17:55
professionalTad McClellan6-Aug-21 17:55 
AnswerRe: What is an archetect? Pin
Gerry Schmitz7-Aug-21 5:22
mveGerry Schmitz7-Aug-21 5:22 
AnswerRe: What is an archetect? Pin
Mycroft Holmes7-Aug-21 12:36
professionalMycroft Holmes7-Aug-21 12:36 
Questioncross compiling a huge codebase from Power++ to c# Pin
sx20088-Jul-21 11:17
sx20088-Jul-21 11:17 
AnswerRe: cross compiling a huge codebase from Power++ to c# Pin
Dave Kreskowiak8-Jul-21 11:43
mveDave Kreskowiak8-Jul-21 11:43 
AnswerRe: cross compiling a huge codebase from Power++ to c# Pin
Mycroft Holmes8-Jul-21 12:55
professionalMycroft Holmes8-Jul-21 12:55 
AnswerRe: cross compiling a huge codebase from Power++ to c# Pin
Gerry Schmitz9-Jul-21 5:47
mveGerry Schmitz9-Jul-21 5:47 
GeneralRe: cross compiling a huge codebase from Power++ to c# Pin
Mycroft Holmes9-Jul-21 12:36
professionalMycroft Holmes9-Jul-21 12:36 
GeneralRe: cross compiling a huge codebase from Power++ to c# Pin
Gerry Schmitz12-Jul-21 8:27
mveGerry Schmitz12-Jul-21 8:27 
AnswerRe: cross compiling a huge codebase from Power++ to c# Pin
jschell17-Jul-21 10:55
jschell17-Jul-21 10:55 
AnswerRe: cross compiling a huge codebase from Power++ to c# Pin
Lothar Behrens 202411-Apr-24 19:36
Lothar Behrens 202411-Apr-24 19:36 
QuestionEasiest Way To Implement Predictive Search On An Intranet Site Pin
Maria Delpiano17-Jun-21 5:25
Maria Delpiano17-Jun-21 5:25 
AnswerRe: Easiest Way To Implement Predictive Search On An Intranet Site Pin
jschell7-Jul-21 6:43
jschell7-Jul-21 6:43 
GeneralRe: Easiest Way To Implement Predictive Search On An Intranet Site Pin
Mycroft Holmes7-Jul-21 13:28
professionalMycroft Holmes7-Jul-21 13:28 
GeneralRe: Easiest Way To Implement Predictive Search On An Intranet Site Pin
User 1407655213-Jul-21 9:23
User 1407655213-Jul-21 9:23 

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.