Cannot serialize parameter of type 'System.Linq.Enumerable… ' when using WCF, LINQ, JSON

后端 未结 3 717
暗喜
暗喜 2020-12-18 03:42

I have a WCF Service. It uses Linq-to-objects to select from a Dictionary. The object type is simple:

public class User 
{
   public Guid Id;
   public Stri         


        
3条回答
  •  醉梦人生
    2020-12-18 04:03

    You need to pass interoperable collections to and from your WCF methods.

    WCF plays best with simple types and arrays.

    Pass in an array from your client and then turn it into an IEnumerable in the service.

    Stuff like IEnumerable is not interoperable, which is what WCF is trying to be.

    There may be a way to get around it with known types, but I always strive to make my components as flexible as possible.

提交回复
热议问题