We help IT Professionals succeed at work.
Get Started

Add fields to a wcf web service

Mark Klein
Mark Klein asked
Last Modified: 2015-02-02
I've built a running WCF web service in C#, and a demo client to consume the service. My web service returns three fields (score, description, ranking) based on a stored procedure query to a SQL Server db.

I need to add a fourth field, IncentiveLevel, that is based partly on score and partly on business rules.  How do I incorporate this into the results class? Here is the relevant code from the services1.svc file:
 public List<TopCrossSells> GetTopCrossSells(string CustomerId, string ProductCategory)
            List<TopCrossSells> results = new List<TopCrossSells>();
            LongbowDemoDataContext dc = new LongbowDemoDataContext();
            int CustomerIdNumber = int.Parse(CustomerId);
            double? Score = 0;
            string ClientKey = "";
            int? Ranking = 1;

            foreach (uspGetTopCrossSellsResult Scores
             in dc.uspGetTopCrossSells(CustomerIdNumber, ProductCategory, ref Score, ref ClientKey, ref Ranking))
                results.Add(new TopCrossSells()
                    Score = (float)Scores.@Score,
                    ClientKey = Scores.@ClientKey,
                    Ranking = Scores.@Ranking
            return results;

Open in new window

Watch Question
Senior Software Engineer
Top Expert 2009
This problem has been solved!
Unlock 1 Answer and 18 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant

An Experts Exchange subscription includes unlimited access to online courses.

Get Started
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE