如何在collection和DataAdapter属性之间添加同步 [英] How to add sync between collection and DataAdapter property

查看:102
本文介绍了如何在collection和DataAdapter属性之间添加同步的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好!
我有以下问题:

我有一个包含SqlDataAdapter

Hi everyone!
I have the following problem:

I have a class that contains SqlDataAdapter and a

SortedList <sqlcommand,string>

的类,该类包含四个由字符串索引的SqlCommand,例如dbCommands["select"].我为SortedList添加了一个属性:

which contains four SqlCommands indexed by a string, for example dbCommands["select"]. I''ve added a property for SortedList:

public SortedList<string, SqlCommand> Commands
{
    get { return this.dbCommands;  }
    set { this.dbCommands = value; }
}



如何在此SortedList和DataAdapter之间添加同步,例如,当更改SortedList值中的任何一个时,此更改应反映在DataAdapter.XXXCommand中,如下所示:



How do I add a sync between this SortedList and DataAdapter, for example, when any of SortedList values is changed this change should reflect in DataAdapter.XXXCommand, like this:

MyClass.Commands["update"] = new SqlCommand();
/* MyClass.SqlDataAdapter.UpdateCommand is changed too */

推荐答案

您是否在问如何在Visual Studio Designer中进行此更新? http://msdn.microsoft.com/zh-cn/library/bb166014(VS.80).aspx还是要在运行时编写在数据适配器中实际使用命令的代码?我想我会尝试使用INotifyPropertyChanged. http://msdn.microsoft.com/zh-cn/library/ms229614.aspx
Are you asking how to do this update within the Visual Studio Designer? http://msdn.microsoft.com/en-us/library/bb166014(VS.80).aspx Or are you asking to write the code that actually makes use of your commands within the data adapter at run-time? I think I''d try using INotifyPropertyChanged. http://msdn.microsoft.com/en-us/library/ms229614.aspx


这篇关于如何在collection和DataAdapter属性之间添加同步的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆