我有一个 WCF 客户端,我需要将 DTO 放入BindingSource中,但是当我尝试将过滤器应用于 BindingSource 时,它不能作为整洁的 List 或 BindingList 工作,因为它们都返回 false IBindingListView.SupportsFiltering
。
我需要使用什么数据类型才能过滤我的列表?
代理 DTO:
namespace MyApp.DataContracts
{
[System.Runtime.Serialization.DataContractAttribute(Name = "ServerSetupDTO", Namespace = "http://example.com/MyApp")]
[System.SerializableAttribute()]
public partial class ServerSetupDTO : object, System.Runtime.Serialization.IExtensibleDataObject
{
[System.Runtime.Serialization.DataMemberAttribute()]
public System.ComponentModel.BindingList<MyApp.DataContracts.DatabaseInfo> GenericPreconfigs
{
//(Snip)
}
//(Snip)
}
[System.Runtime.Serialization.DataContractAttribute(Name = "DatabaseInfo", Namespace = "http://example.com/MyApp")]
[System.SerializableAttribute()]
public partial class DatabaseInfo : object, System.Runtime.Serialization.IExtensibleDataObject
{
[System.Runtime.Serialization.DataMemberAttribute()]
public string AllowedServer
{
//(Snip)
}
//(Snip)
}
}
应用过滤器:
ServerSetupDTO serverSetupDTO = proxyClient.GetServerSetup();
bsServerSettings.DataSource = serverSetupDTO ;
bsPreconfigList.DataMember = "GenericPreconfigs";
bsPreconfigList.DataSource = bsServerSettings;
//This filter never gets applied, bsPreconfigList.SupportsFiltering is false.
bsPreconfigList.Filter = String.Format("AllowedServer = '{0}'", cmbHost.Text);