×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

WebService Entity Framework Call Stored Procedure

WebService Entity Framework Call Stored Procedure

WebService Entity Framework Call Stored Procedure

(OP)
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;
}
}
}

RE: WebService Entity Framework Call Stored Procedure

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<prcYourProcedureNameResultHere>());
} 

Lodlaiden

You've got questions and source code. We want both!
There's a whole lot of Irish in that one.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close