Constructor in WCF DataContract not reflected on Client

前端 未结 3 864
盖世英雄少女心
盖世英雄少女心 2020-12-06 02:41

I need to have some data members get some values when I create an instance of the DataContract on the client. This is not happening using constructors. I have searched throu

3条回答
  •  庸人自扰
    2020-12-06 03:01

    make Proxy class in your client side:

    public class AccountProxy: Account
    {
       public AccountProxy()
       {
             mAccountId = 5;
             mAccountName = "ABC";
       }
    }
    

    and use your proxy class, not generated client class:

    namespace TestClient
    {
        public partial class _Default : System.Web.UI.Page
        {
            protected void Page_Load(object sender, EventArgs e)
            {
                AccountProxy acc = new AccountProxy();
    
            }
        }
    }
    

提交回复
热议问题