C# string concatenation in Lambda expression

Viewed 3443
String qry = "p => p.Title == "Test" && P.Status=0;

myProjects = dataAccessHelper.GetMyDetails(id).
  Where(Append qry string here).ToList();

I am trying to append my query string output to where in Lambda expression. It works fine if I take

myProjects = dataAccessHelper.GetMyDetails(id).
  Where(p => p.Title == "Test" && P.Status=0).ToList(); 

But not like this

myProjects = dataAccessHelper.GetMyDetails(id).
  Where("+ qry +").ToList();

How can I concatenate this and make lambda expression work.

My Controller code

   [HttpGet]
        public virtual ActionResult MyProjects(int? id, string qry)
        {
            var dataAccessHelper = new DataAccessHelper(true);
            IList<ProjectEntity> myProjects;
            if (qry == null)
            {
                myProjects = dataAccessHelper.GetMyProjects(id);
            }
            else
            {
                Expression<Func<ProjectEntity, bool>> expr = qry;
                myProjects = dataAccessHelper.GetMyProjects(id).Where(expr).ToList();

            }

            var myProjectsViewModel = new MyProjectsViewModel() { GetMyProjects =                  myProjects };
            return View(myProjectsViewModel);

        }
2 Answers
Related