文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>Note---Data Contract:DataTable,DataSet,Generic and Collection

Note---Data Contract:DataTable,DataSet,Generic and Collection

时间:2011-04-21  来源:小AI

DataTable and DataSet.

the DT and DS are very common , frequent and important type in .net framework,which is used to interact with database via ADO.NET,by default ,the DT and DS is serializable,so we can define the contracts which accept and return the DT and DS.

As we know,the DT and DS are specific to .net framework,so if our contract accepts and returns them,which will violate the SO principle,because the service consumer can’t recognize the DS and DT.but DS and DT are essential for C# program,how we do? a solution for this is converting the DS and DT to array before we expose them on our service.

another drawback of DS and DT in contract is that you expose you internal data structure to the client,which is not recommended and not safe way.

Generic

Generic is also designed to be specific to .net,so as a principle of SO,we’d better not expose the generic in our contract.but we can use bouned generics in our contract.when the contract with bouned generic is imported to the client,the client will generate the bounded generic to a specific type.

Collection

Collection in .net is also specific to .net framework,but it is so useful in program,so WCF is helpful and clever enough that we can use Collection in our contract without violating the SO principle.because when we expose the Collection in contract at service,the client uses a array instead of corresponding collection.so it does.

Collection Data Contract

while the WCF generates the collection of contract to array, it also provides a better way,which is that we can use CollectionDataContractAttribute decorate a collection used as a data contract,the difference is that the client still keep the collection but not a array.

相关阅读 更多 +
排行榜 更多 +
辰域智控app

辰域智控app

系统工具 下载
网医联盟app

网医联盟app

运动健身 下载
汇丰汇选App

汇丰汇选App

金融理财 下载