我有一个实体框架模型
public partial class Product
{
public Product()
{
this.Designs = new HashSet<Design>();
}
public int BookingProductId { get; set; }
public System.Guid BookingId { get; set; }
public decimal Price { get; set; }
public virtual Booking Booking { get; set; }
public virtual ICollection<Design> Designs { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
...其中我想更新 Price 属性以响应添加到产品中的新设计。我试图按照这个例子:
如何将实体框架 ICollection 更改为 ObservableCollection?
所以我的课如下:
public partial class Product : INotifyPropertyChanged
{
public Product()
{
this.Designs = new ObservableCollection<Design>();
}
public int BookingProductId { get; …Run Code Online (Sandbox Code Playgroud) c# entity-framework observablecollection inotifypropertychanged asp.net-mvc-4
我有一个想法,我想实现它主要涉及将MVC4项目中的控制器分成2个不同的项目.原因是我希望能够为我的网站的内部管理部分和外部客户端部分使用不同的控制器.我想单独更改它们中的每一个,并在我进行更改时向网站添加一个新的DLL ...对站点内部管理部分的更改因此不会影响外部客户端部分的控制器DLL,例如.
有谁知道这是可行的/可取的还是更好的方法来实现我想要实现的目标?
我一直在寻找一些博客文章来尝试为以下要求创建一个合适的解决方案,但我似乎无法将它们拼凑在一起.希望完全有人能提供帮助.
我一直在使用Repository模式和使用Automapper的接口......这是一个精简的例子:
public class BookingRepository : IBookingRepository
{
Entities context = new Entities();
public IEnumerable<BookingDto> GetBookings
{
get { return Mapper.Map<IQueryable<Booking>, IEnumerable<BookingDto>>(context.Bookings); }
}
public BookingDto GetBookingWithProduct(Guid bookingId)
{
return Mapper.Map<BookingDto>(context.Bookings.Include(c => c.Products).SingleOrDefault(c => c.BookingId == bookingId));
}
public void Update(BookingDto bookingDto)
{
var booking = Mapper.Map<Booking>(bookingDto);
context.Entry(booking).State = EntityState.Modified;
}
public void Save()
{
context.SaveChanges();
}
public void Dispose()
{
context.Dispose();
}
}
public interface IBookingRepository : IDisposable
{
IEnumerable<BookingDto> GetBookings { get; }
BookingDto GetBooking(Guid bookingId);
void Update(BookingDto …Run Code Online (Sandbox Code Playgroud) asp.net-mvc unit-of-work repository-pattern automapper entity-framework-5