我現在的程序存儲庫是如下,請建議,我目前使用LINQ2SQL數據上下文每個刀片/ delele /更新LINQ2SQL數據層/庫建議
namespace Lib.Repository
{
public class MotorRenewalDataRepository
{
public MotorRenewalDataRepository()
{
}
public MotorRenewalData GetByID(long id)
{
using(var _context=DatabaseFactory.Create(false))
{
return _context.MotorRenewalDatas.Where(p => p.MotorRenewalDataID == id).FirstOrDefault();
}
}
public MotorRenewalData Insert(MotorRenewalData entity)
{
using (var _context = DatabaseFactory.Create(false))
{
_context.MotorRenewalDatas.InsertOnSubmit(entity);
_context.SubmitChanges();
return entity;
}
}
public void Update(MotorRenewalData entity)
{
using (var _context = DatabaseFactory.Create(true))
{
var dbEntity = _context.MotorRenewalDatas.Where(p => p.MotorRenewalDataID == entity.MotorRenewalDataID)
.FirstOrDefault();
Common.CopyObject<MotorRenewalData>(entity, dbEntity);
_context.SubmitChanges();
}
}
}
}
問題是什麼? – SteadyEddi 2010-04-13 14:07:17