Tôi đang cố gắng trả lại lớp tùy chỉnh từ dịch vụ dữ liệu WCF của mình. lớp tùy chỉnh của tôi là:Không thể trả lại lớp tùy chỉnh từ Dịch vụ dữ liệu WCF
[DataServiceKey("ID")]
public class Applist {
public int ID { get; set; }
public string Name { get; set; }
}
dịch vụ dữ liệu của tôi trông giống như:
public static void InitializeService(IDataServiceConfiguration config)
{
config.RegisterKnownType(typeof(Applist));
config.SetEntitySetAccessRule("*", EntitySetRights.All);
config.SetServiceOperationAccessRule("GetApplications", ServiceOperationRights.AllRead);
}
[WebGet]
public IQueryable<Applist> GetApplications() {
var result = (from p in this.CurrentDataSource.Applications
orderby p.ApplicationName
group p by p.ApplicationName into g
select new Applist { ID = g.Min(p => p.id), Name = g.Key });
return result.AsQueryable();
}
Tuy nhiên khi tôi chạy dịch vụ, nó mang lại cho tôi một lỗi:
Request Error Request Error The server encountered an error processing the request.
The exception message is 'Unable to load metadata for return type
'System.Linq.IQueryable`1[ApplicationService.Applist]' of method
'System.Linq.IQueryable`1[ApplicationService.Applist] GetApplications()'
Các truy vấn cùng chạy một cách hoàn hảo tốt trong LINQPad.
Đổi tên thành WCF Dịch vụ dữ liệu một năm trước .... –
Không sử dụng dịch vụ dữ liệu WCF với VS 2010 và dịch vụ dữ liệu ADO.Net với VS 2008 SP1 tạo sự khác biệt ? – Ashish
Bạn có nhận được giải pháp nào cho điều này không? – genericuser