Search code examples
wcfwcf-data-services

WCF data service in wcf class library from Client


I created a WCF Dataservice and tested using Postman (Chrome extension) which work fine. Then I added the service reference which points the WCF Dataservice in my client C# library.

When I call the Transactions DbSet on my DataService, I get the number of transactions properly however all items in the list were overwritten with the last item in the list. i.e if I have 10 transactions in the database, I get 10 in my list but the data in all items are same which is the last item in the database.

I am using simple LINQ to get the data as shown below

List<Transaction>() tempList = new List<Transaction>(); 
tempList = GetContext().Transactions.ToList();

The weird part is when I catch the query that runs on database using the Fiddler, the output from the database is fine, which means something is happening in my client and overriding all the items in the list with the last item. Can anyone point me how to debug this or how can I catch who is overriding my list.


Solution

  • Got it..found that there is no UNIQUE key on the table, so from client upon deserializing its adding the last found item to the list