当我构建我的 .xsd 时,我必须为每个表选择列,它为表创建了一个模式,对吗?那么,如何让 Select 字符串用作数据适配器新实例的基本 Select 命令,然后根据需要向其附加 Where 和 OrderBy 子句?
这将使我不必使每个 DataAdapter 的字段列表(对于同一个表)与 .xsd 文件中该表的架构保持同步。
有几个 DataAdapter 在某个表模式上工作但在 Where 和 OrderBy 子句中使用不同的参数不是很常见吗?当然,不必为六个 DataAdapter 维护(甚至冗余构建)Select 字符串的字段列表部分,这些 DataAdapter 都在同一个表模式下工作。
我正在设想这样的伪代码:
BaseSelectString = MyTypedDataSet.JobsTable.GetSelectStringFromSchema() // Is there such a method or technique?
WhereClause = " Where SomeField = @Param1 and SomeOtherField = @Param2"
OrderByClause = " Order By Field1, Field2"
SelectString=BaseSelectString + WhereClause + OrderByClause
OleDbDataAdapter adapter = new OleDbDataAdapter(SelectString, MyConn)