none
Domain Service IQueryable<T> exclude value. RRS feed

  • Question

  • I have a EF 4.0 RIA domain service method as below

     public IQueryable<TravelRequestStatus> GetTravelRequestStatuses()
            {
                return this.ObjectContext.TravelRequestStatuses;
            }

    The result set contains a GUID value for the column "RowGUID" in this result set. I want to remove the value for a particular GUID "87F709A8-701F-4268-9A3F-5E3A030121EA" and return the rest of the result set. Please help with the lamdba expression or other approach.
    • Moved by CoolDadTx Tuesday, October 15, 2013 1:46 PM EF related
    Tuesday, October 15, 2013 1:17 PM

Answers

  • Thanks a lot Fred. This was exactly what I was looking for. Also, please let me know how can I check for multiple GUID's instead on a single GUID.
    • Marked as answer by SudiptaC Wednesday, October 16, 2013 6:57 AM
    Wednesday, October 16, 2013 5:32 AM
  • Hi,

    It seems that the "not in" is what you are looking for.

    If it is, please have a try codes with below:

     protected IQueryable<Order> GetOrderExceptOrderID()
            {
                List<string> notinGUIDList = new List<string>() { "O001", "O002" };
                DataBaseFirstDBEntities db = new DataBaseFirstDBEntities();
                //Use this one to return List where IS NOT IN the provided listIDs
                return db.Orders.Where(o => !notinGUIDList.Contains(o.OrderCode));
                //Or use this one to return List where IS IN the provided listIDs
                //return db.Orders.Where(o => notinGUIDList.Contains(o.OrderCode));
            }
    Regards. 

    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Marked as answer by SudiptaC Wednesday, October 16, 2013 6:57 AM
    Wednesday, October 16, 2013 5:54 AM
    Moderator

All replies

  • Hello,

    If I understand correctly, you want to return the result set except GUID "87F709A8-701F-4268-9A3F-5E3A030121EA.

    public IQueryable<TravelRequestStatuses> GetTravelRequestStatuses()
    
            {
    
                DataBaseFirstDBEntities db = new DataBaseFirstDBEntities();
    
                return db.TravelRequestStatuses.Where(t=> t.GUID !=  "87F709A8-701F-4268-9A3F-5E3A030121EA");
    
            }

    If this does not work for you, please let me know.

    Regards.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Wednesday, October 16, 2013 5:08 AM
    Moderator
  • Thanks a lot Fred. This was exactly what I was looking for. Also, please let me know how can I check for multiple GUID's instead on a single GUID.
    • Marked as answer by SudiptaC Wednesday, October 16, 2013 6:57 AM
    Wednesday, October 16, 2013 5:32 AM
  • Hi,

    It seems that the "not in" is what you are looking for.

    If it is, please have a try codes with below:

     protected IQueryable<Order> GetOrderExceptOrderID()
            {
                List<string> notinGUIDList = new List<string>() { "O001", "O002" };
                DataBaseFirstDBEntities db = new DataBaseFirstDBEntities();
                //Use this one to return List where IS NOT IN the provided listIDs
                return db.Orders.Where(o => !notinGUIDList.Contains(o.OrderCode));
                //Or use this one to return List where IS IN the provided listIDs
                //return db.Orders.Where(o => notinGUIDList.Contains(o.OrderCode));
            }
    Regards. 

    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Marked as answer by SudiptaC Wednesday, October 16, 2013 6:57 AM
    Wednesday, October 16, 2013 5:54 AM
    Moderator
  • Thanks a lot for your help Fred.
    Wednesday, October 16, 2013 6:57 AM