locked
Result set appears twice RRS feed

  • Question

  • Hi,

    I'm busy developing a WCF service, but I notice something strange. After a call to the service, the results appear twice. I took screenshots, maybe that explains better. On the serverside everything looks fine :

    The class listCompanyForm contains a collection and a callResult object where errors are stored in case something goes wrong. So this looks ok to me. However on the clientside it looks different, everything appears twice. I see a "Collection" and a "CollectionField" and a "callResult" and a "callResultField". Both contains the same data. And I have no idea what the extensionDataField means. The classes are not derived from IExtensibleDataObject.

    Here is the code of the datacontracts :

    namespace TransmissionService
    {
        [DataContract]
        public  class CompanyForm
        {
            [DataMember(Order = 0)]
            public int Id { get; set; }

            [DataMember(Order = 1)]
            public string Description { get; set; }
        }

        [DataContract]
        public class ListCompanyForm
        {
            [DataMember(Order = 0)]
            public List<CompanyForm> companyFormCollection = new List<CompanyForm>();

            [DataMember(Order = 1)]
            public CallResult callResult = new CallResult();
        }
    }

    And the implementation code :

                

            public ListCompanyForm GetCompanyForms(string UserName, string Password)
            {
                ListCompanyForm listCompanyForm = new ListCompanyForm();

                using (FbConnection con = new FbConnection(Functions.GetConnectionString(UserName, Password)))
                {
                    string SQL = "SELECT VEN_ID, VEN_CODE FROM TBL_VENNOOTSCHAP";

                    try
                    {
                        FbCommand com = new FbCommand(SQL, con);
                        con.Open();
                        FbDataReader rdr = com.ExecuteReader();

                        while (rdr.Read())
                        {
                            listCompanyForm.companyFormCollection.Add(new CompanyForm
                            {
                                Id = Convert.ToInt32(rdr[0]),
                                Description = rdr[1].ToString()
                            });
                        }
                    }
                    catch (Exception e)
                    {
                        listCompanyForm.callResult.Success = false;
                        listCompanyForm.callResult.Errors.Add(e.Message);
                    }
                }

                return listCompanyForm;
            }

    Many thanks in advance !

    Steve

    Tuesday, June 7, 2016 7:05 AM

All replies

  • Hi SteveDeclerck,

    According to your code snippet, it seems ok, please check if your database has duplicate records.

    Best regards,

    Cole Wu


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Sunday, July 10, 2016 5:49 AM
    Moderator