0

This is the inital query.

var DevUsers = db.UserProfiles.Include("Tasks").Include("Projects").Include("FollowerTasks").Select(i => new
        {               
            Tasks = db.Tasks.Where(j => j.AssignedToPersonID == i.PersonID).Where(k => k.QAStatus != "Passed").Select(k => new
            {
                k.Projects,
                k.TaskName,
                k.ViewedByDeveloper,
                k.Status,
                k.QAStatus,
                k.ReleaseStatus,
                k.TaskID,
                k.DisplayTaskID,
                k.EstimatedDeliveryDate,
                k.AssignedToPerson.FirstName,
                Tags = k.Tags.Where(p => p.TagType == "General"),
                Modules = k.Tags.Where(p => p.TagType == "Module"),
                CodeTables = db.CodeTables.Where(l => l.Status == k.Status).FirstOrDefault(),
            }).OrderBy(k => k.ViewedByDeveloper).ThenBy(k => k.CodeTables.DisplayOrder).ThenByDescending(k => k.ReleaseStatus),
            i.PersonID,
            i.FirstName,
            i.LastName,
            i.UserID,
            i.EmailAddress,
        }).OrderBy(i => i.FirstName);

I cannot do any type of query in this DevUsers

DevUsers = DevUsers.Where(m=>m.PersonID==1);

gives error "cannot convert source..."

how can i apply where conditions. I need to apply where in condition here for PersonID(int) and Status(int).

2
  • What type is "PersonID"? Commented Nov 28, 2013 at 6:46
  • 1
    OrderBy return IOrderedEnumerable, Where - IEnumerable Commented Nov 28, 2013 at 6:48

2 Answers 2

3

Your DevUsers is an IOrderedEnumerable<T> and can't be implicitly converted to an IEnumerable<T>, so you should define a new variable like this:

var newDevUsers =  DevUsers.Where(m=>m.PersonID==1);

Or modify your last query using AsEnumerable() like this:

//...
}).OrderBy(i => i.FirstName).AsEnumerable();
DevUsers = DevUsers.Where(m=>m.PersonID==1);
Sign up to request clarification or add additional context in comments.

5 Comments

thank you. but i still cannot search through the Status. DevUsers = DevUsers.Where(m=>m.Tasks.Status==1); the Status is not identified.
@remrowruchan what do you mean? looks like that's not your problem described in the question, you should talk more about that.
i need where condition on PersonID (which worked as you said) and also Status.
@remrowruchan what about other properties? (beside Status), do you see them in the intellisense popup?
Oh now i got it... The Tasks is also IOrderedEnumerable<T> so need to convert it to IEnumerable<T>. thanks
1

Answer to your second question (posted in comment to King King answer) is: m.Tasks is collection (IOrderedEnumerable<T> in this case) and doesn't have Status property.

If you want all tasks to have given status you should use DevUsers = DevUsers.Where(m => m.Tasks.All(t => t.Status==1)).
If you want any task to have given status you should use DevUsers = DevUsers.Where(m => m.Tasks.Any(t => t.Status==1)).

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.