wcf数据服务[WebGet]方法返回一个int [英] wcf data service [WebGet] method returning an int

查看:78
本文介绍了wcf数据服务[WebGet]方法返回一个int的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个返回int的WCF数据服务[WebGet]方法。 (产品表中没有产品)


如何读取结果?

我使用浏览器检查了该方法。


         public void ProductsCount()

        {

            ctx.BeginExecute< int>(新的Uri(uriBase +" / GetNoProducts"),GetProductsCountCompleted,ctx);

        }
        public void GetProductsCountCompleted(IAsyncResult result)

        {

            inventory_db_bigEntities context = result.AsyncState as inventory_db_bigEntities;

            var x = context.EndExecute< int>(result);


           //我如何读取x变量中的int       


        }


UPDATE


也许BeginExecute< int>和EndExecute< int>不是这样的。


在浏览器窗口中,webget方法返回:


< GetNoProducts p1:type =" Edm .Int32"> 223863< / GetNoProducts>

解决方案

您好PaulRusu,


 


更改此内容  var x = context.EndExecute< int>(result);到


  var x =(context.EndExecute< int>(result))。FirstORDefault();




和检查x中的值

I have a WCF data service [WebGet] method returning an int. (no of products in products table)

How can I read it's result?
The method works i checked with the browser.

         public void ProductsCount()
        {
            ctx.BeginExecute<int>(new Uri(uriBase + "/GetNoProducts"), GetProductsCountCompleted, ctx);
        }
        public void GetProductsCountCompleted(IAsyncResult result)
        {
            inventory_db_bigEntities context=result.AsyncState as inventory_db_bigEntities;
            var x = context.EndExecute<int>(result);

           //how do i read the int out of the x variable        
        }

UPDATE

Maybe BeginExecute<int> and EndExecute<int> is not the way to go for it.

In the browser window the webget method returns:

<GetNoProducts p1:type="Edm.Int32">223863</GetNoProducts>

解决方案

Hi PaulRusu,

 

change this  var x = context.EndExecute<int>(result); to

 var x = (context.EndExecute<int>(result)).FirstORDefault();


and check value in x


这篇关于wcf数据服务[WebGet]方法返回一个int的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆