宁静的WCF服务

时间:2014-12-04 13:04:13

标签: c# sql wcf rest

我已经为Windows Phone 8.1创建了一个项目,通过Restful WCF服务连接到远程SQL服务器。

我可以从服务器中选择所有表,然后在表中插入一行。 然而,在插入表格后,当我再次从表格中选择时,不包括新插入的行。

这是我的代码:

[ServiceContract]
public interface IService1
{
    [OperationContract]
    [WebGet(UriTemplate = "GetData",
            RequestFormat=WebMessageFormat.Json,
            ResponseFormat=WebMessageFormat.Json)]
    List<tblKullanıcılar> GetData();

...

public class Service1:IService1
{
    public DataClasses1DataContext data { get; set; }

    List<tblKullanıcılar> IService1.GetData()
    {
        data = new DataClasses1DataContext();
        //List<tblKullanıcılar> donen = new List<tblKullanıcılar>();
        //donen = null;
        //data.tblKullanıcılars.ToList().Clear();
        //donen = data.tblKullanıcılars.ToList();
        var q = (from a in data.GetTable<tblKullanıcılar>() 
                 select a)
                 .ToList<tblKullanıcılar>();

        data.Dispose();
        data = null;
        return q;
    }

并致电服务......

         private async Task CallService()
    {
         listbox1.ItemsSource = null;
         HttpClient httpClient = new System.Net.Http.HttpClient();
         HttpRequestMessage request = new HttpRequestMessage(
                                            HttpMethod.Get,
                                            "http://localhost:18901/Service1.svc/GetData");
         HttpResponseMessage response = await httpClient.SendAsync(request);
         string data = await response.Content.ReadAsStringAsync();
         var sonuc = JsonConvert.DeserializeObject<Kullanici[]>(data);
         listbox1.ItemsSource = sonuc;
         listbox1.UpdateLayout();
         sonuc = null;
         data = null;
         //var dialog = new MessageDialog(data);
         //await dialog.ShowAsync();
     }

有人有想法吗?

提前谢谢

0 个答案:

没有答案