首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

WCF 强类型数据集 fill 表返回有关问题 高分100

2012-02-08 
WCF 强类型数据集 fill 表返回问题 高分100类型化的数据集C# codepublic class Service1 : IService1{publ

WCF 强类型数据集 fill 表返回问题 高分100
类型化的数据集

C# code
    public class Service1 : IService1    {        public DataEntityTier.NorthwindDataSet.CustomersDataTable GetCustomers()        {            DataEntityTier.NorthwindDataSet northwind = new DataEntityTier.NorthwindDataSet();            DataEntityTier.NorthwindDataSetTableAdapters.CustomersTableAdapter CustomersTableAdapter1                = new DataEntityTier.NorthwindDataSetTableAdapters.CustomersTableAdapter();            CustomersTableAdapter1.Fill(northwind.Customers);             return northwind.Customers;         }    }--------------------------------    [ServiceContract]    [XmlSerializerFormat]     public interface IService1    {        [OperationContract]        DataEntityTier.NorthwindDataSet.CustomersDataTable GetCustomers();    }客户端            using (Service1Client poxy = new Service1Client())            {                dataGridView1.DataSource = poxy.GetCustomers();            }   



运行结果返回一张空表 !!!

请教高人

[解决办法]
lz 认证和数据源或者数据协议神马的没啥关系。OData也可以基于Https,证书做更安全的验证

不用 OData 直接用 EF 用 BasicHttpBinding 也可以的。用强类型的 DataSet 也可以的。

但是强类型的 DataSet 类型比较复杂,序列化有可能有问题不过没试过。

我只是建议你使用EF,因为EF比DataSet更容易序列化。甚至像我例子里的那样,可以做到POCO的简单类型。

http://blog.csdn.net/fangxinggood/article/details/6452549


[解决办法]
强类型的 DataSet 类型比较复杂,序列化有可能有问题 这是对的; 可以将它 移流的方式发回来

或者

C# code
    public class Service1 : IService1    {        public DataTable GetCustomers()        {            DataEntityTier.NorthwindDataSet northwind = new DataEntityTier.NorthwindDataSet();            DataEntityTier.NorthwindDataSetTableAdapters.CustomersTableAdapter CustomersTableAdapter1                = new DataEntityTier.NorthwindDataSetTableAdapters.CustomersTableAdapter();            CustomersTableAdapter1.Fill(northwind.Customers);             Datatable dt = new DataTable();            dt.Tablename = "jj";             dt = northwind.Customers.copy();                      return dt;         }    }     [ServiceContract]    [XmlSerializerFormat]     public interface IService1    {        [OperationContract]        DataTable GetCustomers();    } 

热点排行