© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•15mo ago•
3 replies
v0fbu1vm

Data retrieval EF-core

private static readonly Expression<Func<Shift, ShiftDTO>> MapShiftToDto = shift => new ShiftDTO
    {
        Id = shift.Id,
        Date = shift.Date,
        Start = shift.Start,
        End = shift.End,
        Break = shift.Break,
        Overtime = shift.Overtime,
        DepartmentId = shift.DepartmentId,
        Department = new DepartmentDTO
        {
            Id = shift.DepartmentId,
            Name = shift.Department.Name,
            Color = shift.Department.Color,
        }
    };
private static readonly Expression<Func<Shift, ShiftDTO>> MapShiftToDto = shift => new ShiftDTO
    {
        Id = shift.Id,
        Date = shift.Date,
        Start = shift.Start,
        End = shift.End,
        Break = shift.Break,
        Overtime = shift.Overtime,
        DepartmentId = shift.DepartmentId,
        Department = new DepartmentDTO
        {
            Id = shift.DepartmentId,
            Name = shift.Department.Name,
            Color = shift.Department.Color,
        }
    };
I have a question regarding this. The department info is quite important on the client side. I do have a query that fetches the departments. I could for instance just get the department on the client side. The problem is that it makes the process very complicated. Also what if the departments on the client side are dirty meaning outdated or another user just created another department on some other device. All of a sudden the department will not be available. Should i also return the department when returning the shifts?
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Ef core seed (data)
C#CC# / help
12mo ago
EF-Core data reference [Answered]
C#CC# / help
4y ago
EF Core
C#CC# / help
2y ago
❔ Advice on Data modeling-ef core
C#CC# / help
3y ago