这代码很……虽然我用 vim 写起来不累,但读代码感觉也很郁闷。能化简不?
ProductAdapter.SelectCommand = new SQLiteCommand(ProductSelectCmd, Connection);
ProductAdapter.InsertCommand = new SQLiteCommand(ProductInsertCmd, Connection);
ProductAdapter.UpdateCommand = new SQLiteCommand(ProductUpdateCmd, Connection);
ProductAdapter.DeleteCommand = new SQLiteCommand(ProductDeleteCmd, Connection);
ClientAdapter.SelectCommand = new SQLiteCommand(ClientSelectCmd, Connection);
ClientAdapter.InsertCommand = new SQLiteCommand(ClientInsertCmd, Connection);
ClientAdapter.UpdateCommand = new SQLiteCommand(ClientUpdateCmd, Connection);
ClientAdapter.DeleteCommand = new SQLiteCommand(ClientDeleteCmd, Connection);
TradeAdapter.SelectCommand = new SQLiteCommand(TradeSelectCmd, Connection);
TradeAdapter.InsertCommand = new SQLiteCommand(TradeInsertCmd, Connection);
TradeAdapter.UpdateCommand = new SQLiteCommand(TradeUpdateCmd, Connection);
TradeAdapter.DeleteCommand = new SQLiteCommand(TradeDeleteCmd, Connection);
BillAdapter.SelectCommand = new SQLiteCommand(BillSelectCmd, Connection);
BillAdapter.InsertCommand = new SQLiteCommand(BillInsertCmd, Connection);
BillAdapter.UpdateCommand = new SQLiteCommand(BillUpdateCmd, Connection);
BillAdapter.DeleteCommand = new SQLiteCommand(BillDeleteCmd, Connection);
ProductAdapter.SelectCommand = new SQLiteCommand(ProductSelectCmd, Connection);
ProductAdapter.InsertCommand = new SQLiteCommand(ProductInsertCmd, Connection);
ProductAdapter.UpdateCommand = new SQLiteCommand(ProductUpdateCmd, Connection);
ProductAdapter.DeleteCommand = new SQLiteCommand(ProductDeleteCmd, Connection);
ClientAdapter.SelectCommand = new SQLiteCommand(ClientSelectCmd, Connection);
ClientAdapter.InsertCommand = new SQLiteCommand(ClientInsertCmd, Connection);
ClientAdapter.UpdateCommand = new SQLiteCommand(ClientUpdateCmd, Connection);
ClientAdapter.DeleteCommand = new SQLiteCommand(ClientDeleteCmd, Connection);
TradeAdapter.SelectCommand = new SQLiteCommand(TradeSelectCmd, Connection);
TradeAdapter.InsertCommand = new SQLiteCommand(TradeInsertCmd, Connection);
TradeAdapter.UpdateCommand = new SQLiteCommand(TradeUpdateCmd, Connection);
TradeAdapter.DeleteCommand = new SQLiteCommand(TradeDeleteCmd, Connection);
BillAdapter.SelectCommand = new SQLiteCommand(BillSelectCmd, Connection);
BillAdapter.InsertCommand = new SQLiteCommand(BillInsertCmd, Connection);
BillAdapter.UpdateCommand = new SQLiteCommand(BillUpdateCmd, Connection);
BillAdapter.DeleteCommand = new SQLiteCommand(BillDeleteCmd, Connection);
解决方案 »
- .NET快速开发整合框架(RDIFramework.NET)
- 计算机屏幕1024*768上1mm有几个像素,纵向和横向的分辨率是否相同。
- TreeView树形目录的问题,,,,,,?
- 怎么把图片保存到SQL中?
- winform 程序 datagrid 列时间显示格式
- 急急急急!!!!!!自定义控件的动态改变位置与大小
- .net技术作家请进~~~~~~~~~~~~~~~
- 最简单的ajax+vs2005的聊天室
- 怎么定义用字符串索引的数组,使用方式是类似Session["username"]这样用。
- (求救)用.NET下的winform在知道网址的情况下,怎么遍历这个网址下的所有文件(也就是目录下的所有文件)?
- 水晶报表分组汇总
- 谁能解释一下static变量
public DataAdapter CreateAdapterFromConfiguration(string tableName, SQLLiteConnection connection)
{
DataAdapter da = new DataAdapter(); da.SelectCommand = new SQLLiteCommand(GetCommandTextFromConfiguration(tableName, "Select"), connection);
da.InsertCommand = new SQLLiteCommand(GetCommandTextFromConfiguration(tableName, "Insert"), connection);
da.UpdateCommand = new SQLLiteCommand(GetCommandTextFromConfiguration(tableName, "Update"), connection);
da.DeleteCommand = new SQLLiteCommand(GetCommandTextFromConfiguration(tableName, "Delete"), connection);
return da;
}public string GetCommandTextFromConfiguration(string tableName, string commandName)
{
// 从一个XML配置文件中读取内容
// ...
}
配置文件参考下面的格式:<Configuration>
<Table Name="Product">
<Command Name="Select">SELECT * FROM Product</Command>
<Command Name="Insert">INSERT Product VALUES(@p1, @p2, ...)</Command>
<Command Name="Update">...</Command>
<Command Name="Delete">...</Command>
</Table>
</Configuration>
ProductAdapter = CreateAdapterFromConfiguration("Product", Connection);
ClientAdapter = CreateAdapterFromConfiguration("Client", Connection);
TradeAdapter = CreateAdapterFromConfiguration("Trade", Connection);
BillAdapter = CreateAdapterFromConfiguration("Bill", Connection);