LINQ Query with dynamic where clause based on search criteria that is NOT part of the returned object -
I have an alumni table with 60+ columns. I have created an alumni search result class in which only a few useful fields For which I need to display in a table of search results. It is an MVC2 app so I want to keep objects clean (in other words, I do not want to pass 60+ field objects in my scene). I am trying to build my alumni research research as part of my query against alumni but it worked fine but I want to add dynamically where the clots are only in search critics objects only - problem That my search criteria are not required in the result object (for example the last name).
Try first:
var scholarship = iuaaOlcEntities.AlumniRecords; If (searchCriteria.lastname! = Null) alumni vacancies Where (r = & gt; ar.lastname == searchCriteria.lastname); Alumni of Return Selection (AR => New Alumni FindCode {person_id = ARPsar_ID, FullName = R. integer name, city = RCT, state = RTT, AMP_name = R.M.P.name, AMP_title = AR .emp_title});
Where does this neglect just for the nickname where I can not break after choosing because there is no last name field for the alumni search.
Try another: ar = search.Results = This format works, but I have a dozen search criteria and want to add a value to "ar.lastname == searchCriteria.lastname" searchCriteria.lastname. Any ideas for this LINQ newb?
var alumni = iuaaOlcEntities.AlumniRecords.AsQueryable (); If (searchCriteria.lastname! = Faucet) Alumni Vacancies = Alumni Where (r = & gt; ar.lastname == searchCriteria.lastname); Alumni of Return Selection (AR => New Alumni FindCode {person_id = ARPsar_ID, FullName = R. integer name, city = RCT, state = RTT, AMP_name = R.M.P.name, AMP_title = AR .emp_title});
Comments
Post a Comment