+ Reply to Thread
Results 1 to 2 of 2

Thread: Enumerable FirstOrDefault

  1. #1
    Junior Member
    Join Date
    Jan 2012
    Posts
    13

    Enumerable FirstOrDefault

    the following code will return an Enumerable of dynamic objects.
    Code:
    protected override dynobject Get(int id)
    { 
        Func<dynobject, bool> check = x => x.ID == id;
        return  Enumerable.Where<dynobject>(this.Get(), check);
    }
    how do I select the FirstOrDefault so it is a single object not an Enumerable?

  2. #2
    Junior Member
    Join Date
    Jan 2012
    Posts
    45
    You could use FirstOrDefault instead of Where:
    Code:
    protected override dynobject Get(int id)
    { 
        Func<dynobject, bool> check = x => x.ID == id;
        return Enumerable.FirstOrDefault<dynobject>(this.Get(), check);
    }
    That should help you , good luck

+ Reply to Thread

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts