Answer the question
In order to leave comments, you need to log in
Three-layer architecture for ADO.NET, problems when returning DBNull and little things
Hello. After reading this article about the three-layer data access architecture, I decided to finally learn how to write everything normally and according to the rules. Everything is fine so far, but there are a couple of questions:
1. If at this stage:
UserVO userVO = new UserVO();
DataTable dataTable = new DataTable();
dataTable = _userDAO.searchByName(name);
foreach (DataRow dr in dataTable.Rows)
{
userVO.idUser = Int32.Parse(dr["t01_id"].ToString());
userVO.firstname = dr["t01_firstname"].ToString();
userVO.lastname = dr["t01_lastname"].ToString();
userVO.email = dr["t01_email"].ToString();
}
return userVO;
Answer the question
In order to leave comments, you need to log in
1. Use Nullable in the model.
2. Yes.
But, IMHO, I would look at the Entity Framework, NHibernate or other ORMs, since ADO, although it works quickly, is now only suitable for projects at the support stage. If you write everything anew (as I understand it with you), then it is better to take a step into the present. Of the benefits: much less need to write code for working with the database, LINQ.
EntityFramework
NHibernate
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question