I'm experimenting with LinqToSql and the MVP pattern and having trouble setting on a good design. I'm using Asp.net 3.5 (not MVC)
Here is a example
public interface IMyBusinessCardView
{
string Field1 { get; set; }
string Field2 { get; set; }
string Field15 { get; set; }
}
public class MyBusinessCardPresenter
{
private IMyBusinessCardView _view;
private MyBusinessCard _myCard;
public void ViewClickedSave()
{
_myCard.SaveNewBusinessCard(_view);
}
public void LoadView()
{
_myCard.LoadMyBusinessCardToView(_view);
}
}
public class MyBusinessCard
{
public void SaveNewBusinessCard(IMyBusinessCardView view)
{
using (var context = new DataContext())
{
var card = new BusinessCard()
{
Field1 = view.Field1
};
context.BusinessCards.InsertOnSubmit(card);
context.SubmitChanges();
}
}
public void LoadMyBusinessCardToView(IMyBusinessCardView view)
{
// Query using Linq to Sql and set in view
view.Field1 = card.Fields1;
}
}
I'm thinking The view and controller are very thin, that's good I guess. The "model" has access to the view, is that bad? Should I introduce DTO objects or should I use the LinqToSql generated entities.
Please provide feedback to the design.