Click here to Skip to main content
15,891,184 members
Please Sign up or sign in to vote.
1.44/5 (2 votes)
When I execute the following code:

C#
var resultDistrictServiceLogReportDetails =
                    _sOAPNoteRepository.GetAll()
                                       .Where(i => i.CreatedBy == therapist.Id &&
                                                    i.DateofService < searchendDate &&
                                                    i.DateofService >= searchstartDate &&
                                                    i.TimeLogClientList.TimeLog.TimeLogActivity.SOAPReq.Value &&
                                                    i.Employee.Service != null &&
                                                    i.TimeLogClientList.TimeLog.TimeLogContractSite.ContractType
                                                        .ContractType1.ToLower().Equals(Utilities.SCHOOLDISTRICT.ToLower()) &&
                                                    i.TimeLogClientList.TimeLog.Errors == null && i.TimeLogClientList.TimeLog.Rejected == null &&
                                                    (i.TimeLogClientList.TimeLog.Void == null || !i.TimeLogClientList.TimeLog.Void.Value))
                                       .Select(i => new
                                       {
                                           i.Client,
                                           i.TimeLogClientList.Grade,
                                           i.DateofService,
                                           i.Time,
                                           i.TimeLogActivity.ActivityDesc,
                                           i.TimeLogClientList.TimeLog.TimeLogCategory.Category,
                                           i.ActivityId,
                                           i.ContractSiteId,
                                           i.TimeLogContractSite.ContractSite,
                                           i.TimeLogClientList.TherapistId,
                                           ServiceId = i.Employee.ServiceId,
                                           i.SNote,
                                           i.ONote,
                                           i.ANote,
                                           i.PNote,
                                           SignedDate = i.TimeLogClientList.TimeLog.SignedDate,
                                           i.Location,
                                           i.Employee,
                                           ID = i.CreatedBy,
                                           i.TimeLogClientList.TimeLog.ElapsedTime,
                                           i.SupSignedBy,
                                           i.SupSignedDate,
                                           i.Employee3,
                                           cptcode = (from cpt in _activityCPTCodeRepository.GetAll().Where((x => x.ActivityId == i.TimeLogActivity.Id && x.ServiceId == i.Employee.Service.Id))
                                                      select cpt.CptCode)
                                       }).ToList();


after executing this code i got a error message that is

"LINQ to Entities does not recognize the method 'System.Linq.IQueryable`1[LifeSpan.Data.ActivityCptCode] GetAll()' method, and this method cannot be translated into a store expression."

only last column generate issue other wise this code working fine.

Any help or suggestion would be appreciated.
Posted
Updated 29-Jun-15 22:42pm
v2
Comments
virusstorm 30-Jun-15 12:24pm    
How is _sOAPNoteRepository defined?
Shambhoo kumar 1-Jul-15 2:28am    
Thanks for your comment, I have resolve it myself.

1 solution

I have resolve it my self. only adding a single function "AsEnumerable()" before Select function. :)
C#
var resultDistrictServiceLogReportDetails =
                   _sOAPNoteRepository.GetAll()
                                      .Where(i => i.CreatedBy == therapist.Id &&
                                                   i.DateofService < searchendDate &&
                                                   i.DateofService >= searchstartDate &&
                                                   i.TimeLogClientList.TimeLog.TimeLogActivity.SOAPReq.Value &&
                                                   i.Employee.Service != null &&
                                                   i.TimeLogClientList.TimeLog.TimeLogContractSite.ContractType
                                                       .ContractType1.ToLower().Equals(Utilities.SCHOOLDISTRICT.ToLower()) &&
                                                   i.TimeLogClientList.TimeLog.Errors == null && i.TimeLogClientList.TimeLog.Rejected == null &&
                                                   (i.TimeLogClientList.TimeLog.Void == null || !i.TimeLogClientList.TimeLog.Void.Value)).AsEnumerable()
                                      .Select(i => new
                                      {
                                          i.Client,
                                          i.TimeLogClientList.Grade,
                                          i.DateofService,
                                          i.Time,
                                          i.TimeLogActivity.ActivityDesc,
                                          i.TimeLogClientList.TimeLog.TimeLogCategory.Category,
                                          i.ActivityId,
                                          i.ContractSiteId,
                                          i.TimeLogContractSite.ContractSite,
                                          i.TimeLogClientList.TherapistId,
                                          ServiceId = i.Employee.ServiceId,
                                          i.SNote,
                                          i.ONote,
                                          i.ANote,
                                          i.PNote,
                                          SignedDate = i.TimeLogClientList.TimeLog.SignedDate,
                                          i.Location,
                                          i.Employee,
                                          ID = i.CreatedBy,
                                          i.TimeLogClientList.TimeLog.ElapsedTime,
                                          i.SupSignedBy,
                                          i.SupSignedDate,
                                          i.Employee3,
                                          cptcode = _activityCPTCodeRepository.GetAll()
                                              .Where(x => x.ActivityId == i.TimeLogActivity.Id && x.ServiceId == i.Employee.Service.Id)
                                              .Select(x => x.CptCode).FirstOrDefault().ToString()
                                      }).ToList();
 
Share this answer
 
Comments
Andreas Gieriet 1-Jul-15 13:13pm    
It seems to be your (bad) habit to ask a question on CP and quickly answer it yourself. Think first! If you solved it yourself, make it a comment on the question that you "did not think before asking the question".
Please remove such "solutions".
Regards
Andi
Shambhoo kumar 2-Jul-15 3:06am    
Dear @Andreas Gieriet, i had post that solution after 24 hours of asked this question. really i try alot but did not get any solution that's why i was posting my question on CP, and for you kind of information, just i want to say something "It's not bad habbit in my knowledge", may be this solution helpful for other too, that's why i had decided to post my solution there. I really appreciate you experience and respect their too, but please think "these type of comment may be hurt someone". Thanks for your advice.
Regard
Sham

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900