I have a need here and I'm having a hard time implementing I have an application with Decorator Pattern and would like to update the data of my components by taking the information directly from the database, but I am not finding a legal way to do it even using the repository pattern.
This is my component
public abstract class Component
{
public abstract string GetName();
public abstract double GetPrice();
public abstract string GetDescription();
public abstract int GetMinutesToPrepare();
public abstract int GetNumberTable();
}
My ConcreteComponent
namespace Restaurant.Lib.Components.MainCourse
{
public class RoastLamb : Dishes
{
private string Description = "An Indian roast lamb you can't miss: learn how to prepare a roast leg of lamb indian style, marinated with mixed spices.";
private int MinutesToPrepare = 30;
private string Name = "Main Course - Roast Lamb With Indian Spices";
private int NumberTable = 0;
private double Price = 53.00;
public RoastLamb(int numberTable)
{
NumberTable = numberTable;
}
public override int GetNumberTable() => NumberTable;
public override string GetDescription() => Description;
public override int GetMinutesToPrepare() => MinutesToPrepare;
public override string GetName() => Name;
public override double GetPrice() => Price;
}
}
and the above data would like to fetch from the database.
I made a layer of DAO with same ado.net but it falls into a circular reference problem because my "Entity" is actually declared within my component which is the default of the Decorator.
Does anyone have a workable solution?