在WCF数据服务中指定空的IQueryable中的列?
我有一个DataService与以下查询:
public IQueryable<MyData> MyDataList => myDataList.AsQueryable();
我在Excel 2016
连接到这个数据服务。 一切正常,但是当清单是空的,我得到以下错误信息。
The query did not run or the Data Model could not be accessed. Here's the error message we got: An Evaluate statement cannot return a table without columns
客户端(Excel)似乎需要一个对象来成功确定列。 为什么? 是否可以告诉客户有关列而不需要一个对象?
你不能先检查结果查询,看它是否包含任何内容,并返回实际的数据或默认的数据?
var defaultList = new List<MyData>(); public IQueryable<MyData> MyDataList = (myDataList.Any())?myDataList.AsQueryable():defaultList.AsQueryable();