コード例 #1
0
        public T ConvertDBLookUpToModelLookUp <T, U>(int id, string propertyName, MagicBooksDBEntities context)
            where T : IDBLookup, new()
            where U : class, IDBLookup
        {
            var book = context.Books.Where(b => b.Id == id).FirstOrDefault();

            PropertyInfo propertyInfo = book.GetType().GetProperty(propertyName);

            if (propertyInfo != null)
            {
                try
                {
                    var lookUpProperty = propertyInfo.GetValue(book, null) as U;
                    return(new T
                    {
                        Id = lookUpProperty.Id,
                        Name = lookUpProperty.Name
                    });
                }
                catch (Exception)
                {
                }
            }
            return(default(T));
        }
コード例 #2
0
 public DeliveryRepository()
 {
     context = new MagicBooksDBEntities();
 }
コード例 #3
0
 public BookRepository()
 {
     context = new MagicBooksDBEntities();
 }
コード例 #4
0
 public PaymentRepository()
 {
     context = new MagicBooksDBEntities();
 }
コード例 #5
0
 public OrderRepository()
 {
     context = new MagicBooksDBEntities();
 }