2012-03-01 2 views
0

나는 다음과 같은 코드를 가지고 :LINQ - 문자열에 날짜 시간 다시

  result = from i in _dbContext.Meetings 
        where i.UserInvitedID == CurrentUserID && i.MeetingStatus == null && i.AllowedTime.AllowedDate.Day >= date 
        //where i.UserInvitedID == CurrentUserID && i.MeetingStatus == null && EntityFunctions.TruncateTime(i.AllowedTime.AllowedDate.Day) >= date 
        select new ITW2012Mobile.Core.DataTable.MeetingModel2() 
        { 
         Name = i.UserInviter.FirstName + " " + i.UserInviter.LastName, 
         Company = i.UserInviter.Company, 
         MeetingID = i.MeetingID, 
         Time = EntityFunctions.AddMinutes(EntityFunctions.AddHours(i.AllowedTime.AllowedDate.Day, i.AllowedTime.Hour).Value, i.AllowedTime.Minute).Value.ToString("0:dddd, MMMM d, yyyy 0:t"), 
         Image = i.UserInviter.ProfileImage, 
         Username = i.UserInviter.aspnet_User.UserName 
        }; 

시간 문자열입니다. 물론, 내가 얻을

Exception error: {"LINQ to Entities does not recognize the method 'System.String ToString()' method, and this method cannot be translated into a store expression."}

내 경우에는 올바르게 작성하는 방법?

답변

0

L2E에는 .ToString을 사용할 수 없습니다. 그것은 EF 제한 사항입니다. .AsEnumerable()

+0

후, 예를 들어, 내가 그것을 어떻게 할 수 -

당신은 오브젝트 공간에 그렇게해야? 선택 부분에서는 시간을 설정해야합니다. 맞습니까? – John

+1

당신은 다음과 같은 일을합니다 :'Select new {A = iA, B = iB}) AsEnumerable() : Select (i => new MeetingModel2 {A = iAToString (...), B = iB), ' –

+0

will 매우 긴 스크립트가 있어야합니다. (하나의 DB와 결합 할 수없는 약 10 개의 비슷한 위치가 있습니다.) – John