Here is simple repository pattern that I use to access data in my database. I would like some advice on how to improve this code. Commenting on my code quality is also welcome too!
public static class ProdRepository
{
private static Entities context = null;
public static Entities Context
{
get
{
if (context == null)
{
return new Entities();
}
else
return context;
}
}
/// <summary>
/// Getting Outbound list in selected period of dates
/// </summary>
/// <param name="dateFrom">begin date</param>
/// <param name="dateTo">end date</param>
/// <returns>Outbound List</returns>
public static List<OutboundModel> GetOutboundsByDate(DateTime dateFrom, DateTime dateTo)
{
var q = from o in Context.wms_Outbound
where o.CreateDT <= dateTo && o.CreateDT >= dateFrom
select new OutboundModel
{
Id = o.Id,
Code = o.Code,
CreationDate = o.CreateDT,
RootQuantity = o.RootQuantity
};
return q.ToList();
}
}