I have this situation:
public class busOrder: IbusOrder
{
public Order vOrder { get; set; }
MyDataContext db = new MyDataContext();
public busOrder(int pOrderId)
{
vOrder = db.Orders.SingleOrDefault(p => p.Id == pOrderId);
}
public int SaveNew()
{
...
}
public int GetStatus()
{
...
}
}
As you may have noticed, Order is a table in my datacontext and the constructor “fills” vOrder and I can do that very easily with link (one line).
But when I’m making calls to use the objects atributes I have to do it like this:
busOrder openOrder = new busOrder(someId);
then I have to do this to get the columns:
openOrder.vOrder.Date;
openOrder.vOrder.Status;
Is there any way for me to make this values more easily accessible (like openOrder.Date, without having to manually create and set them one by one in the class?
You could also use Dynamic Language Runtime.
EDIT: Well if you’re using .NET 4.0 you could implement something like this: