Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. WCF and WF
  4. [Datamember] WCF

[Datamember] WCF

Scheduled Pinned Locked Moved WCF and WF
csharpwcfbusinesshelptutorial
8 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Member 2321293
    wrote on last edited by
    #1

    Hi All, i Designed my project in 3 tier and WCF method but i don't know how to use the data member. while in WCF... below are sample: (Business logic layer) namespace mySample.BLL { [DataContract] public class bllCountry : ibllCountry private string _CountryCode; [DataMember] public string CountryCode { get { return _CountryCode; } set { _CountryCode = value; } } } (interface layer) namespace mySample.SVR { [ServiceContract] public interface ibllCountry { [OperationContract] string GetCountryCode(); [OperationContract] int GetLengthCode(); [OperationContract] int GetLengthName(); } } (GUI layer) in the class in order to get the method from BLL i write ChannelFactory CountryFactory = new ChannelFactory("Country"); ibllCountry countryProxy = CountryFactory.CreateChannel(); txtCountryCode.MaxLength = countryProxy.GetLengthCode(); in normal class reference, i know is written(get and set) bllCountry CountryObj = new bllCountry(); txtCountryCode.text = CountryObj._CountryCode; or CountryObj._CountryCode = txtCountryCode.text; But how to i SET and GET the value from Datamember in WCF way? Please private a help or sample. Thank you. By CSTan

    P 1 Reply Last reply
    0
    • M Member 2321293

      Hi All, i Designed my project in 3 tier and WCF method but i don't know how to use the data member. while in WCF... below are sample: (Business logic layer) namespace mySample.BLL { [DataContract] public class bllCountry : ibllCountry private string _CountryCode; [DataMember] public string CountryCode { get { return _CountryCode; } set { _CountryCode = value; } } } (interface layer) namespace mySample.SVR { [ServiceContract] public interface ibllCountry { [OperationContract] string GetCountryCode(); [OperationContract] int GetLengthCode(); [OperationContract] int GetLengthName(); } } (GUI layer) in the class in order to get the method from BLL i write ChannelFactory CountryFactory = new ChannelFactory("Country"); ibllCountry countryProxy = CountryFactory.CreateChannel(); txtCountryCode.MaxLength = countryProxy.GetLengthCode(); in normal class reference, i know is written(get and set) bllCountry CountryObj = new bllCountry(); txtCountryCode.text = CountryObj._CountryCode; or CountryObj._CountryCode = txtCountryCode.text; But how to i SET and GET the value from Datamember in WCF way? Please private a help or sample. Thank you. By CSTan

      P Offline
      P Offline
      Parwej Ahamad
      wrote on last edited by
      #2

      As per your post, you are trying to use private variable of your class i.e. "_CountryCode" instead of propery "CountryCode". So please try it and let us know if this is not working.

      Parwej Ahamad ahamad.parwej@gmail.com

      M 1 Reply Last reply
      0
      • P Parwej Ahamad

        As per your post, you are trying to use private variable of your class i.e. "_CountryCode" instead of propery "CountryCode". So please try it and let us know if this is not working.

        Parwej Ahamad ahamad.parwej@gmail.com

        M Offline
        M Offline
        Member 2321293
        wrote on last edited by
        #3

        Hi, OK, Now i public all my Variable example: public string _CountryCode; [DataMember] public string CountryCode { get { return _CountryCode; } set { _CountryCode= value; } } ibllCountry countryProxy = CountryFactory.CreateChannel(); to get the Length of my Country code i can get it like that : countryProxy.GetLengthCountryCode(); But how to SET country Code and GET country Code ? Please guide. I still don't know how to use Get and Set, Please to provide more clear answer.

        P 1 Reply Last reply
        0
        • M Member 2321293

          Hi, OK, Now i public all my Variable example: public string _CountryCode; [DataMember] public string CountryCode { get { return _CountryCode; } set { _CountryCode= value; } } ibllCountry countryProxy = CountryFactory.CreateChannel(); to get the Length of my Country code i can get it like that : countryProxy.GetLengthCountryCode(); But how to SET country Code and GET country Code ? Please guide. I still don't know how to use Get and Set, Please to provide more clear answer.

          P Offline
          P Offline
          Parwej Ahamad
          wrote on last edited by
          #4

          Hi you need basic example of WCF application. So either search it on google or find below URL this may help you. After that if you are stuck anywhere then let us know. WCF (Windows Communication Foundation) Example[^]

          M 1 Reply Last reply
          0
          • P Parwej Ahamad

            Hi you need basic example of WCF application. So either search it on google or find below URL this may help you. After that if you are stuck anywhere then let us know. WCF (Windows Communication Foundation) Example[^]

            M Offline
            M Offline
            Member 2321293
            wrote on last edited by
            #5

            Hi, The provided sample, i already read and try before. and i also learn the WCF from this sample also. but this sample does not shown me how to use the data member but only the class function only. all i needed is only how to use the Get and Set only. like normal reference: CountryClass objCountryClass = new CountryClass(); to Get ls_CountryCode = objCountryCodeClass.CountryCode; to Set objCountryCodeClass.CountryCode = "Sweden"; In WCF environment. i really don't know how to use it. Please provide a direct sample.... By CSTan

            P 1 Reply Last reply
            0
            • M Member 2321293

              Hi, The provided sample, i already read and try before. and i also learn the WCF from this sample also. but this sample does not shown me how to use the data member but only the class function only. all i needed is only how to use the Get and Set only. like normal reference: CountryClass objCountryClass = new CountryClass(); to Get ls_CountryCode = objCountryCodeClass.CountryCode; to Set objCountryCodeClass.CountryCode = "Sweden"; In WCF environment. i really don't know how to use it. Please provide a direct sample.... By CSTan

              P Offline
              P Offline
              Parwej Ahamad
              wrote on last edited by
              #6

              I have modified your code as per your requirement.

              using System;
              using System.Collections.Generic;
              using System.Linq;
              using System.Text;
              using System.ServiceModel;

              namespace mySample.SVR
              {
              [ServiceContract]
              public class ibllCountry
              {
              [OperationContract]
              string GetCountryCode();

                  \[OperationContract\]
                  void SetCountryCode(string countryCode);
                  
                  \[OperationContract\]
                  int GetLengthCode();
              
                  \[OperationContract\]
                  void SetLengthCode(int lengthCode);
                  
                  \[OperationContract\]
                  int GetLengthName();
              
                  \[OperationContract\]
                  void SetLengthName(int lengthName);
              }
              

              }

              using System;
              using System.Collections.Generic;
              using System.Linq;
              using System.Text;
              using System.ServiceModel;

              namespace mySample.SVR
              {
              [ServiceBehavior(InstanceContextMode = InstanceContextMode.Single)]
              public class bllCountry : ibllCountry
              {
              Country country = new Country();

                  string ibllCountry.GetCountryCode()
                  {
                      return country.CountryCode;
                  }
              
                  void ibllCountry.SetCountryCode(string countryCode)
                  {
                      country.CountryCode = countryCode;
                  }
              
                  int ibllCountry.GetLengthCode()
                  {
                      return country.LengthCode;
                  }
              
                  void ibllCountry.SetLengthCode(int lengthCode)
                  {
                      country.LengthCode = lengthCode;
                  }
              
                  int ibllCountry.GetLengthName()
                  {
                      return country.LengthName;
                  }
              
                  void ibllCountry.SetLengthName(int lengthName)
                  {
                      country.LengthName = lengthName;
                  }
              }
              

              }

              using System;
              using System.Collections.Generic;
              using System.Linq;
              using System.Text;
              using System.Runtime.Serialization;

              namespace mySample.SVR
              {
              [DataContract]
              public class Country
              {
              [DataMember]
              public string CountryCode;

                  \[DataMember\]
                  public int LengthCode;
              
                  \[DataMember\]
                  public int LengthName;        
              }
              

              }

              Try to implement it and let me know if still you are facing problem.

              Parwej Ahamad ahamad.parwej@gmail.com

              M 1 Reply Last reply
              0
              • P Parwej Ahamad

                I have modified your code as per your requirement.

                using System;
                using System.Collections.Generic;
                using System.Linq;
                using System.Text;
                using System.ServiceModel;

                namespace mySample.SVR
                {
                [ServiceContract]
                public class ibllCountry
                {
                [OperationContract]
                string GetCountryCode();

                    \[OperationContract\]
                    void SetCountryCode(string countryCode);
                    
                    \[OperationContract\]
                    int GetLengthCode();
                
                    \[OperationContract\]
                    void SetLengthCode(int lengthCode);
                    
                    \[OperationContract\]
                    int GetLengthName();
                
                    \[OperationContract\]
                    void SetLengthName(int lengthName);
                }
                

                }

                using System;
                using System.Collections.Generic;
                using System.Linq;
                using System.Text;
                using System.ServiceModel;

                namespace mySample.SVR
                {
                [ServiceBehavior(InstanceContextMode = InstanceContextMode.Single)]
                public class bllCountry : ibllCountry
                {
                Country country = new Country();

                    string ibllCountry.GetCountryCode()
                    {
                        return country.CountryCode;
                    }
                
                    void ibllCountry.SetCountryCode(string countryCode)
                    {
                        country.CountryCode = countryCode;
                    }
                
                    int ibllCountry.GetLengthCode()
                    {
                        return country.LengthCode;
                    }
                
                    void ibllCountry.SetLengthCode(int lengthCode)
                    {
                        country.LengthCode = lengthCode;
                    }
                
                    int ibllCountry.GetLengthName()
                    {
                        return country.LengthName;
                    }
                
                    void ibllCountry.SetLengthName(int lengthName)
                    {
                        country.LengthName = lengthName;
                    }
                }
                

                }

                using System;
                using System.Collections.Generic;
                using System.Linq;
                using System.Text;
                using System.Runtime.Serialization;

                namespace mySample.SVR
                {
                [DataContract]
                public class Country
                {
                [DataMember]
                public string CountryCode;

                    \[DataMember\]
                    public int LengthCode;
                
                    \[DataMember\]
                    public int LengthName;        
                }
                

                }

                Try to implement it and let me know if still you are facing problem.

                Parwej Ahamad ahamad.parwej@gmail.com

                M Offline
                M Offline
                Member 2321293
                wrote on last edited by
                #7

                Hi, This is real great and helpful. Now i know how to use the Get and Set in WCF. The sample you provided really helpful and solve my problem and i learn it also. Really Thanks to you. Thank You~! By CSTan

                P 1 Reply Last reply
                0
                • M Member 2321293

                  Hi, This is real great and helpful. Now i know how to use the Get and Set in WCF. The sample you provided really helpful and solve my problem and i learn it also. Really Thanks to you. Thank You~! By CSTan

                  P Offline
                  P Offline
                  Parwej Ahamad
                  wrote on last edited by
                  #8

                  In Interface define the Propery instead of Method and as well these property implement in your bll... class file.

                  Parwej Ahamad ahamad.parwej@gmail.com

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups