Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Jonas 123 posts 206 karma points
    Apr 05, 2016 @ 09:19
    Jonas
    0

    SQL

    What am I doing wrong, ...

    This wont work.

    e.Query.Where("BookingCategory = 'Child'");

    or this..

    e.Query.Where("BookingCategory = @0","'Child'");

    (Column name is "BookingCategory")

  • Comment author was deleted

    Apr 05, 2016 @ 09:37

    In which event are you doing this?

  • Jonas 123 posts 206 karma points
    Apr 05, 2016 @ 09:38
    Jonas
    0

    public class EventHandlerscs4 : ApplicationEventHandler { protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext) { UIOMatic.Controllers.PetaPocoObjectController.BuildingQuery += PetaPocoObjectController_BuildingQuery; }

        void PetaPocoObjectController_BuildingQuery(object sender, UIOMatic.QueryEventArgs e)
        {
    
            if (e.CurrentType == typeof(tcAdminTodaysChildActivity))
            {
                var DateNow = DateTime.Now;
                var theDate = Convert.ToDateTime(DateNow.ToString("yyyy-MM-dd"));
    
                e.Query.Where("HotelSiteRootId = @0 AND BookingCategory = 'Child' AND DATEPART(yy, ActivityStartTime) = " + theDate.Year + " AND DATEPART(mm, ActivityStartTime) = " + theDate.Month + "AND DATEPART(dd, ActivityStartTime) = " + theDate.Day + "", UmbracoContext.Current.Security.CurrentUser.StartContentId);
    
            }
    
    
        }
    }
    
  • Comment author was deleted

    Apr 05, 2016 @ 10:05

    So the other filters work? Or they all fail?

  • Jonas 123 posts 206 karma points
    Apr 05, 2016 @ 10:50
    Jonas
    0

    The other filters work fine, both HotelSiteRootId (int) and Date (DateTime).

  • Comment author was deleted

    Apr 05, 2016 @ 11:50

    Hmm don't see why it shouldn't work, are you sure the correct code is getting executed?

Please Sign in or register to post replies

Write your reply to:

Draft