© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•17mo ago•
32 replies
Rename

How to setup shared/common data in a web app

I've been working on a legacy project with .NET Framework 4.6.
there is a Shift class and initially it had this code in its Shift entity class:

        public static Shift None => Database.Find<Shift>(s => s.Department == null && s.IsNone);

        public static Shift DayOff => Database.Find<Shift>(s => s.Department == null && s.IsDayOff);
        public static Shift None => Database.Find<Shift>(s => s.Department == null && s.IsNone);

        public static Shift DayOff => Database.Find<Shift>(s => s.Department == null && s.IsDayOff);


now I'm updating everything to .NET 8 and trying to use clean architecture, I'm using Entity Framewokr 8.

It does not make sense to use direct DB calls in the entity class, these Shifts are all saved in the DB and could be edited anytime
but the None and DayOff shifts are used very often.

an example is GetShift() method for a staff which has something like this:

public Shift GetShift(DateTime date)
{

    var contract = GetContract(date);
    if (contract == null)
        return Shift.None;
...
}
public Shift GetShift(DateTime date)
{

    var contract = GetContract(date);
    if (contract == null)
        return Shift.None;
...
}


I'm a bit lost on what would be the best way to set this up.
I could pass those shifts to the GetShift method from a service but I'm wondering if there's a better solution,
this GetShift method is used in a lot of .Where clauses also.
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

✅ How to setup environment variables in Azure Web App
C#CC# / help
11mo ago
✅ AppContext in web api project
C#CC# / help
3y ago
Best solution to shared Web component in a WPF application
C#CC# / help
4mo ago
how to use SignInManager.SignInAsync in blazor web app?
C#CC# / help
3y ago