贫血模式与领域驱动模式 区别 这样对么?
关于贫血模式与领域驱动模式
贫血模式:以下为购物车DEMO(加入一个订单和订购商品使用同一张表)
[model.cs]
public class user
{
public int userid { get; set; }
public string name { get; set; }
}
public class bill//订单
{
public int billid { get; set; }
public int goodsid { get; set;}
public int userid { get; set; }
}
public class goods
{
public int goodsid{ get; set; }
public string goodsname{ get; set; }
}
[dao.cs]
public class billdao
{
public bool InsertBill(bill obj)
{
//数据验证
//insert....略
}
public bool DeleteBill(bill obj)
{
//数据验证
//delete....略
}
....略
}
[service.cs]//服务网层
public class billservice
{
public bool InsertBill(bill obj)
{
return billdao.InsertBill(obj);
}
public bool DeleteBill(bill obj)
{
return billdao.DeleteBill(obj);
}
....略
}
=========================================================================================================
领域模式:
[model.cs]
public class user
{
public int userid { get; set; }
public string name { get; set; }
}
public class bill//订单
{
public int billid { get; set; }
public int goodsid { get; set;}
public int userid { get; set; }
public bool InsertBill(bill obj)
{
//数据验证
return billdao.InsertBill(obj);
}
public bool DeleteBill(bill obj)
{
//数据验证
return billdao.InsertBill(obj);
}
}
public class goods
{
public int goodsid{ get; set; }
public string goodsname{ get; set; }
}
[dao.cs]
public class billdao
{