首页 / 网页编程 / ASP.NET / 自己动手写ASP.NET ORM框架(一):目标效果预览
自己动手写ASP.NET ORM框架(一):目标效果预览2011-04-24 博客园 奋斗最终实现后达到的效果,只需写少量代码就可实现CURD操作。DAL层代码:StudentDAL代码public class StudentDAL
{
EntityManager entityManager = EntityManagerFactory.CreateEntityManager();
public StudentDAL() { }
public StudentDAL(IDbTransaction transaction)
{
entityManager.Transaction = transaction;
}
public List<StudentEntity> FindAll()
{
return entityManager.FindAll<StudentEntity> ();
}
public int Save(StudentEntity entity)
{
return entityManager.Save(entity);
}
public int Update(StudentEntity entity)
{
return entityManager.Update(entity);
}
public int Remove(StudentEntity entity)
{
return entityManager.Remove(entity);
}
public int Remove(object id)
{
return entityManager.Remove<StudentEntity> (id);
}
public List<StudentEntity> FindById(object id)
{
return entityManager.FindById<StudentEntity> (id);
}
public List<StudentEntity> FindByProperty(string propertyName,object value)
{
return entityManager.FindByProperty<StudentEntity>(propertyName, value);
}
}