我想知道Microsoft.Practices.EnterpriseLibrary.Data.dll
是什么,为什么我们要使用这个程序集。
这个dll有什么好处?
我想创建一个三层架构的项目,并且想知道执行sql查询的最佳方法是什么。
我应该使用这个dll还是选择简单的SqlCommand
和DataAdapter
。
目前我是这样工作的:
(DAL文件中的代码:)
public void Insert(long id)
{
connection.Open();
SqlCommand dCmd = new SqlCommand("test_procedure", connection);
dCmd.CommandType = CommandType.StoredProcedure;
try
{
dCmd.Parameters.AddWithValue("@id", id);
dCmd.ExecuteNonQuery();
}
catch
{
throw;
}
finally
{
dCmd.Dispose();
connection.Close();
connection.Dispose();
}
}
我不确定我是否正在以正确的方式工作,或者是否应该更好地使用 Microsoft.Practices.EnterpriseLibrary.Data
并使用 DatabaseFactory
进行工作。