zoukankan      html  css  js  c++  java
  • WCF(Codefirst)

    Codefirst与Contractfirst相对应,先对代码进行编写,然后进行服务的定义!

    项目一:类库项目。先定义完相应的数据实体,然后定义服务。

        [DataContract(Name = "People")]

        public class People//数据实体类

        {

            private string _name;

            private int _age;

            private string _hometown;

     

            [DataMember(Name = "P_Name")]

            public string Name

            {

                get

                {

                    return _name;

                }

                set

                {

                    _name = value;

                }

            }

     

            [DataMember(Name = "P_Age")]

            public int Age

            {

                get

                {

                    return _age;

                }

                set

                {

                    _age = value;

                }

            }

     

            [DataMember(Name = "P_Hometown")]

            public string Hometown

            {

                get

                {

                    return _hometown;

                }

                set

                {

                    _hometown = value;

                }

            }

    }

      [ServiceContract]

        public interface IPeopleContract //定义服务

        {

            [OperationContract]

            void SetMan(People man);

     

            [OperationContract]

            People GetMan();

        }

     

        public class PeopleContract : IPeopleContract //针对服务的实现

        {

            People _man;

            #region IPeopleContract 成员

     

            public void SetMan(People man)

            {

                _man = man;

            }

     

            public People GetMan()

            {

                return _man;

            }

     

            #endregion

        }

  • 相关阅读:
    hibernate各种状态
    Persistence createEntityManagerFactory方法使用
    JS数组学习笔记
    ES6笔记之参数默认值(译)
    JS是按值传递还是按引用传递?
    linux awk命令详解
    Linux Shell笔记之sed
    类似微信红包随机分配js方法
    ionic tabs隐藏完美解决
    mustache 获取json数据内数组对象指定元素的方法
  • 原文地址:https://www.cnblogs.com/hometown/p/2834582.html
Copyright © 2011-2022 走看看