本文介绍了如何使用WCF返回多个值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我有一个(EMP)的sql表,列是(empid int,empname字符串,salary varchar,deptno int).这里以empid作为主键. (已经插入了一些行).为此,我需要创建wcf服务,即wcf服务接受empid并返回剩余的值,例如empname,salary,deptno.并在该wcf服务中能够插入员工详细信息.[插入详细信息将保存到sql EMP表中).对于该要求,我如何在.net中编写WCF服务.请任何人帮我.

提前打个招呼.

nareshrajuu.

hi all,

i have a sql table as (EMP), columns are (empid int,empname string,salary varchar,deptno int). here empid as primary key. (some rows are inserted already).for that i need to create wcf service i.e wcf service accepts empid and return the remaining values like empname,salary,deptno. and also in that wcf service able to insert the employee details.[insert details will save into sql EMP table). for that requirement how can i write WCF Service in .net. please any one help to me.

thnaks in advance.

nareshrajuu.

推荐答案



using System.ServiceModel;

namespace Example
{
    public class EmployeeDetailsResponse
    {
        public string Name { get; set; }
        public string Salary { get; set; }
    }

    public class EmployeeSaveDetailsRequest
    {
        public string Name { get; set; }
        public string Salary { get; set; }
    }

    [ServiceContract]
    public interface ISomeoperation
    {
        [OperationContract]
        public EmployeeDetailsResponse GetEmpDetails();
        [OperationContract]
        public void SaveEmployeeDetails(EmployeeSaveDetailsRequest employeeSaveDetailsRequest);
    }

    public class SomeOperation : ISomeoperation
    {
        public EmployeeDetailsResponse GetEmpDetails()
        {
            //Implemet the operation
            return new EmployeeDetailsResponse(); // by filling the EmployeeDetailsResponse
        }

        public void SaveEmployeeDetails(EmployeeSaveDetailsRequest employeeSaveDetailsRequest)
        {
            //Implemet the operation
        }
    }

}



:)



:)


这篇关于如何使用WCF返回多个值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-02 19:46