Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

WebService Entity Framework Call Stored Procedure

Status
Not open for further replies.

BBBD69

Programmer
Aug 9, 2012
2
0
0
US
I am new to Webservices so any help world be great.

I have created a WCF project, C# 4.0. I have my OperationContract and my DataContract setup like below. I also have a edmx.cs page that contant the SP. In my service page(also below) I am trying to retun the data but get an erro that the conversion fails.


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

namespace EPCS_WebService
{

[ServiceContract]
public interface IEPCSService
{
[OperationContract]
GetProcessList GetList(int intLine);
}

[DataContract]
public class GetProcessList
{
[DataMember]
public int ProcessID { get; set; }
[DataMember]
public string Process { get; set; }
[DataMember]
public int Station { get; set; }
[DataMember]
public string StationDesc { get; set; }
[DataMember]
public Boolean BarCodePassThru { get; set; }
[DataMember]
public int NbrPassThruScanFld { get; set; }
[DataMember]
public string PassThruDestHost { get; set; }
[DataMember]
public int PassThruDestPort { get; set; }
[DataMember]
public int InactiveTimeout { get; set; }
[DataMember]
public int CommitVehicleTimeout { get; set; }
[DataMember]
public int VehicleListRefreshInterval { get; set; }
}
}


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

namespace EPCS_WebService
{

public class EPCS_Service : IEPCSService
{
public GetProcessList GetList(int intLine)
{
T02_EPCSEntities efProcList = new T02_EPCSEntities();

var spQuery = efProcList.GetProcessList(intLine);

if (spQuery != null)
{
return TranslateProcessList(spQuery);
}
}

private GetProcessList TranslateProcessList(GetProcessList spQuery)
{
GetProcessList GetProcessList = new GetProcessList();
GetProcessList.ProcessID = spQuery.ProcessID;
GetProcessList.Process = spQuery.Process;
GetProcessList.Station = spQuery.Station;
GetProcessList.BarCodePassThru = spQuery.BarCodePassThru;
GetProcessList.NbrPassThruScanFld = spQuery.NbrPassThruScanFld;
GetProcessList.InactiveTimeout = spQuery.InactiveTimeout;
GetProcessList.CommitVehicleTimeout = spQuery.CommitVehicleTimeout;
GetProcessList.VehicleListRefreshInterval = spQuery.VehicleListRefreshInterval;
return GetProcessList;
}
}
}
 
What line is your conversion failing on?

Are you explicitly casting your bit field in the db to a bit when you do your final select? You should be able to check the type of the flag in your dbml.
I've had problems with it casting it to an int sometimes. I've had to massage the dbml code behind because it refused to accept it was a bit (be careful doing this).

You may be also having a problem if you aren't explicitly casting your results in the public GetProcessList GetList(int intLine) function
Your procedure "should" always return headers, which would correlate to an empty data set, so it will never be null.

Code:
public GetProcessList GetList(int intLine)
{
T02_EPCSEntities efProcList = new T02_EPCSEntities();
return TranslateProcessList(efProcList.GetProcessList(intLine).ToList<[red]prcYourProcedureNameResultHere[/red]>());
}

Lodlaiden

You've got questions and source code. We want both!
There's a whole lot of Irish in that one.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top