Cannot convert from system...IList<class> to class[]</class>
-
Please could somebody help... My brains gone dead :doh: I'm trying to pass the following to a wcf service
public IList<tbItem> GetItemsWhereIn (IList<tbClass> iclass)
{
iServiceClient svc = new iServiceClient();
IList<tbItem> list = svc.FindItems(iclass);return list;
}The problem is passing parameter iclass to svc.FindItems error Cannot convert from system...IList<tbClass> to tbClass[] The wcf service is setup as
public interface iService{
[OperationContract]
List<tbItem> FindItems(IList<tbClass> iclass);}And the linq query as
public List<tbItem> FindItems(IList<tbClass> iclass)
{
...linq code working correctly
}If you could point the way I would be very greatful :-D
-
Please could somebody help... My brains gone dead :doh: I'm trying to pass the following to a wcf service
public IList<tbItem> GetItemsWhereIn (IList<tbClass> iclass)
{
iServiceClient svc = new iServiceClient();
IList<tbItem> list = svc.FindItems(iclass);return list;
}The problem is passing parameter iclass to svc.FindItems error Cannot convert from system...IList<tbClass> to tbClass[] The wcf service is setup as
public interface iService{
[OperationContract]
List<tbItem> FindItems(IList<tbClass> iclass);}And the linq query as
public List<tbItem> FindItems(IList<tbClass> iclass)
{
...linq code working correctly
}If you could point the way I would be very greatful :-D
I think you need to tell the Client Service Reference to generate the Client proxy using genertic Lists rather than arrays (Lists<T>, IList<T> and other collection types are normally sent up and down the wire as T[] unless you tell the service reference to generate the proxy with something else:
- Right click your service reference
- Select Configure Service Reference
- In the Collection Type drop down select System.Collections.Generic.List
Note that you can't set the Value to IList<T> as Services don't play well with Interfaces / OO in general.
CCC solved so far: 2 (including a Hard One!)
-
I think you need to tell the Client Service Reference to generate the Client proxy using genertic Lists rather than arrays (Lists<T>, IList<T> and other collection types are normally sent up and down the wire as T[] unless you tell the service reference to generate the proxy with something else:
- Right click your service reference
- Select Configure Service Reference
- In the Collection Type drop down select System.Collections.Generic.List
Note that you can't set the Value to IList<T> as Services don't play well with Interfaces / OO in general.
CCC solved so far: 2 (including a Hard One!)
Thanks for answer, this did the trick I just needed to then change this line
IList list = svc.FindItems(iclass.ToList());
:-D