Jump to content

mikev1976

Members
  • Posts

    26
  • Joined

  • Last visited

About mikev1976

  • Birthday 03/17/1976

Profile Information

  • Location
    37066

mikev1976's Achievements

Newbie

Newbie (1/7)

0

Reputation

  1. The problem seems to be near the beginning: select cast(count(*) as INT) I change it to (select cast(count(*) as INT) and the query runs. Now the next question is what do I change to get that ( to show up when VS used Nhibernate to build the query?
  2. I run SQL Server Profiler. I think this is the query that is failing: exec sp_executesql N'select TOP (@p0) icallappoi0_.CallAppointmentId as col_0_0_, icallappoi0_.StartDate as col_1_0_, icallappoi0_.CallAppointmentStatusTypeId as col_2_0_,user3_.UserId as col_3_0_, sponsor5_.SponsorId as col_4_0_, user3_.NameFirst as col_5_0_, user3_.NameLast as col_6_0_,select cast(count(*) as INT)from [HealthTools].Outreach_Core.Calls calls9_whereicallappoi0_.CallAppointmentId=calls9_.CallAppointmentId) as col_7_0_, user4_.UserId as col_8_0_, user4_.NameFirst as col_9_0_,user4_.NameLast as col_10_0_, sponsor5_.SponsorCode as col_11_0_, timezones8_.TimeZoneId as col_12_0_, timezones8_.Abbreviation as col_13_0_,case when icallappoi0_.CallAppointmentTypeId=1 then 1 else 0 end as col_14_0_, sponsor5_.SponsorId as col_15_0_, icallappoi0_.CreatedDate as col_16_0_,(select cast(max(calls10_.CallDate) as DATETIME) from [HealthTools].Outreach_Core.Calls calls10_ where icallappoi0_.CallAppointmentId=calls10_.CallAppointmentId) as col_17_0_,icallappoi0_.RiskTypeId as col_18_0_, sponsor5_.SponsorId as SponsorId51_0_, sponsor5_.SponsorId as SponsorId51_1_, sponsor5_.DatafeedPassword as Datafeed2_51_0_,sponsor5_.SponsorCode as SponsorC3_51_0_, sponsor5_.Name as Name51_0_, sponsor5_.LessonResetDate as LessonRe5_51_0_, sponsor5_.CreatedDate as CreatedD6_51_0_,sponsor5_.ParentId as ParentId51_0_, sponsor5_.DatafeedPassword as Datafeed2_51_1_, sponsor5_.SponsorCode as SponsorC3_51_1_, sponsor5_.Name as Name51_1_,sponsor5_.LessonResetDate as LessonRe5_51_1_, sponsor5_.CreatedDate as CreatedD6_51_1_, sponsor5_.ParentId as ParentId51_1_from [HealthTools].Outreach_Core.CallAppointments icallappoi0_left outer join [HealthTools].Member.Users user1_ on icallappoi0_.CalleeId=user1_.UserIdleft outer join [HealthTools].Member.Users user2_ on icallappoi0_.CalleeId=user2_.UserIdleft outer join [HealthTools].Member.Users user3_ on icallappoi0_.AssignedCallerId=user3_.UserIdleft outer join [HealthTools].Member.Users user4_ on icallappoi0_.CalleeId=user4_.UserIdleft outer join [HealthTools].Sponsor.Sponsors sponsor5_ on user4_.SponsorId=sponsor5_.SponsorIdleft outer join [HealthTools].Member.TimeZones timezones8_ on user4_.TimeZone=timezones8_.TimeZoneIdwhere icallappoi0_.CallAppointmentStatusTypeId=@p1order by user1_.NameLast asc, user2_.NameFirst asc',N'@p0 int,@p1 int',@p0=15,@p1=1 It tells me: Msg 156, Level 15, State 1, Line 4Incorrect syntax near the keyword 'select'.Msg 102, Level 15, State 1, Line 7Incorrect syntax near ')'.Msg 156, Level 15, State 1, Line 10Incorrect syntax near the keyword 'as'.
  3. I am trying to send a query in VS 2010 for our web application: var firstHraIdFromCallAppointment = _session.Query<ICallAppointment>().Select(x => x.Callee.HealthAssessments.Any(hra => hra.CompletedDate != null) ? x.Callee.HealthAssessments.Where(hra => hra.CompletedDate != null).OrderByDescending(hra => hra.CompletedDate).FirstOrDefault().Id : Guid.Empty).FirstOrDefault() ; I can't see anything wrong with the query. But it gives me the following error: Exception of type 'Antlr.Runtime.NoViableAltException' was thrown. [.First[system.Guid](.Select[HealthTools.Core.Domain.Model.Outreach.ICallAppointment,System.Guid](NHibernate.Linq.NhQueryable`1[HealthTools.Core.Domain.Model.Outreach.ICallAppointment], Quote((x, ) => (.Any[HealthTools.Core.Domain.HealthAssessment.Entities.HRA](x.Callee.HealthAssessments, (hra, ) => (DateTime.op_Inequality(hra.CompletedDate, NULLp1)), ) ? .First[HealthTools.Core.Domain.HealthAssessment.Entities.HRA](.OrderByDescending[HealthTools.Core.Domain.HealthAssessment.Entities.HRA,System.Nullable`1[[system.DateTime, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]](.Where[HealthTools.Core.Domain.HealthAssessment.Entities.HRA](x.Callee.HealthAssessments, (hra, ) => (DateTime.op_Inequality(hra.CompletedDate, NULLp3)), ), (hra, ) => (hra.CompletedDate), ), ).Id : p2)), ), )] Any clues as to why or where to start?
×
×
  • Create New...