locked
Return specific columns in ADO.NET Data Services RRS feed

  • Question

  • I have the following codes and I got "Request Error" message.

    config.SetEntitySetAccessRule("*",EntitySetRights.All);

    config.SetServiceOperationAccessRule("*",ServiceOperationRights.All);

    [WebGet]
    public IQueryable<customer_order> GetCustomerOrder(int CustID)
    {
         var qry = (from o in CurrentDataSource.Order
                      from c in CurrentDataSource.Customer
                      where o.customer_id == c.customer_id && c.customer_id == CustID
                      select new customer_order
                      {
                          OrderID = o.order_id,
                          OrderDate = o.order_date,
                          OrderStatus = o.status,
                          CustAddress = c.Address,
                          CustNotes  = c.Notes
                      };

         return qry.AsQueryable();
    }


    public class customer_order
    {
         public int OrderID {get; set;}
         public DateTime OrderDate {get;set;}   
         public Boolean OrderStatus {get;set;}
         public string CustAddress {get;set;}
         public string CustNotes {get;set;}
    }

    Is this possible in ADO.NET Data Services?
    Thanks,
    JFJ

     
    • Moved by Amadeo Casas - MSFT Thursday, October 29, 2009 9:01 PM Wrong forum (From:ASMX Web Services and XML Serialization)
    • Moved by Yichun_Feng Monday, November 2, 2009 9:14 AM Data Services issue (From:ADO.NET DataSet)
    Thursday, October 29, 2009 7:14 PM

Answers

  • If you're using ADO.net data services v1.0 then projections aren't supported - you can only select whole entities.

    If you install ado.net data services v1.5 CTP2 then projections ARE supported and your query should work.

    Dave
    Tuesday, November 3, 2009 3:20 PM

All replies

  • Hi JFJ,

    Since your thread is more related to Data Services, I'll move this thread to Data Services forum.
    You will get better answer in that forum.


    Thanks!
    Yichun Feng

    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Monday, November 2, 2009 9:12 AM
  • Hi,

    If you're getting a request error, the best way to debug the failure is to get more information about the error. For more details see for example this post: http://weblogs.asp.net/sergeyzwezdin/archive/2009/03/19/debugging-ado-net-data-services.aspx.

    I tried a code very similar to yours and it works for me just fine.

    Thanks,
    Vitek Karas [MSFT]
    Monday, November 2, 2009 9:41 AM
    Moderator
  • If you're using ADO.net data services v1.0 then projections aren't supported - you can only select whole entities.

    If you install ado.net data services v1.5 CTP2 then projections ARE supported and your query should work.

    Dave
    Tuesday, November 3, 2009 3:20 PM