这项wcf服务有效吗



接口

[ServiceContract]
public interface Idemo
{
    [OperationContract]
    [WebGet(UriTemplate = "check?Value1={id}&Value2={name}&Value3={city}",
ResponseFormat = WebMessageFormat.Xml, 
BodyStyle = WebMessageBodyStyle.Bare)]
    string GetData(string id,string name);
}

public class demo : Idemo
{
public string GetData(string id,string name,string city) 
    {           
       DataTable tb;
        tb = con.GetDataTable("query");
        tb.TableName = "data";                     
        System.IO.StringWriter writer = new System.IO.StringWriter();
        tb.WriteXml(writer, XmlWriteMode.IgnoreSchema, false);
        return writer.ToString();
    }
}

返回表看起来像下面

sem sub1 sub2 sub3
 1   50   40   30
 2   60   20   40

界面设计好吗?我没有使用任何合同。还有其他加速的方法吗?

我听说将DataSet转换为自定义DataContract并发送它。在我的场景中,这可能吗?

如果您有性能问题,它不在您发布的代码中。

用于获取数据的方法的名称是"getDataTable",您还提到了DataSet的使用。

数据集的使用有开销,您应该考虑优化如何从数据库中获取数据。

相关内容

最新更新