当前位置:编程学习 > C#/ASP.NET >>

WebService 传值为什么不能强制转换

webservice  

 [WebMethod(Description = "aa")]
        public  CustomerDeviceInfoEntity GetNamefromCustomerid(int customerid)
        {
            CustomerDeviceInfoEntityCollection coll = CustomerDeviceInfoEntity.SelectWhere(" customerid='" + customerid + "'");
            if (coll.Count > 0)
                return coll[0];
            else
                return null;
        }


调用页 
  CustomerDeviceInfoEntity ent = new CustomerDeviceInfoEntity();
            ent  = (CustomerDeviceInfoEntity)web.GetNamefromCustomerid(11);
            this.TextBox1.Text = ent.RecordDateTime.ToString();

编译后提示错误
无法将类型“DemoWeb.localhost.CustomerDeviceInfoEntity”转换为“IDH.DAO.CustomerDeviceInfoEntity” D:\mxy\DemoWeb\DemoWeb\WebForm1.aspx.cs 48 18 DemoWeb

请问这个怎么调用啊

--------------------编程问答-------------------- 难道不支持强制转换吗 --------------------编程问答--------------------
引用 楼主 mxy801127 的回复:
webservice  

 [WebMethod(Description = "aa")]
        public  CustomerDeviceInfoEntity GetNamefromCustomerid(int customerid)
        {
            CustomerDeviceInfoEntityCollection coll = CustomerDeviceInfoEntity.SelectWhere(" customerid='" + customerid + "'");
            if (coll.Count > 0)
                return coll[0];
            else
                return null;
        }


调用页 
  CustomerDeviceInfoEntity ent = new CustomerDeviceInfoEntity();
            ent  = (CustomerDeviceInfoEntity)web.GetNamefromCustomerid(11);
            this.TextBox1.Text = ent.RecordDateTime.ToString();

编译后提示错误
无法将类型“DemoWeb.localhost.CustomerDeviceInfoEntity”转换为“IDH.DAO.CustomerDeviceInfoEntity” D:\mxy\DemoWeb\DemoWeb\WebForm1.aspx.cs 48 18 DemoWeb

请问这个怎么调用啊

webservice 返回的是xml格式的 你这个是一个模型 怎么可能呢 --------------------编程问答-------------------- 全部带上完整的命名空间,例如IDH.DAO.CustomerDeviceInfoEntity
补充:.NET技术 ,  ASP.NET
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,