Copied to clipboard

Flag this post as spam?

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


  • Nigel Wilson 944 posts 2076 karma points
    Aug 19, 2016 @ 03:42
    Nigel Wilson
    0

    Custom Query

    Hey Tim

    Another thing I have discovered is my custom table has an archived column for "deleted" entries.

    Ideally I'd love to be able to add a "WHERE" clause to filter out the archived items. Appreciate this is very specific (as per my other post) but thought I'd throw it out there for consideration.

    Cheers

    Nigel

  • Comment author was deleted

    Aug 19, 2016 @ 06:54

    Yeah that's possible :) you can use the event model to setup the where (you can look at the example project for inspiration)

    https://github.com/TimGeyssens/UIOMatic/blob/master/src/Example/Startup.cs

    ALso this post provides some details http://www.nibble.be/?p=493

  • Nigel Wilson 944 posts 2076 karma points
    Aug 19, 2016 @ 19:00
    Nigel Wilson
    0

    Awesome - Monday's job at work all sorted...

    Cheers

  • Nigel Wilson 944 posts 2076 karma points
    Aug 21, 2016 @ 20:30
    Nigel Wilson
    0

    Hey Tim

    Below is my code as per your example however it's not getting hit...

    I set a break point in the ApplicationStarted method and that gets hit, but I cannot step into the query building method.

    using Umbraco.Core;
    using Umbraco.Core.Persistence;
    
    namespace Web
    {
        public class Startup : ApplicationEventHandler
        {
            protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
            {
                UIOMatic.Controllers.PetaPocoObjectController.BuildedQuery += PetaPocoObjectController_BuildedApplicationStatusQuery;
            }
    
            private void PetaPocoObjectController_BuildedApplicationStatusQuery(object sender, UIOMatic.QueryEventArgs e)
            {
    
                if (e.TableName == "NZTR_ApplicationStatus")
                {
                    e.Query = Umbraco.Core.Persistence.Sql.Builder
                        .Append("SELECT NZTR_ApplicationStatus.ApplicationStatusId, NZTR_ApplicationStatus.Name, NZTR_ApplicationStatus.Description, NZTR_ApplicationStatus.color, NZTR_ApplicationStatus.AgedAnalysisNoDaysOK, NZTR_ApplicationStatus.AgedAnalysisNoDaysWarn, NZTR_ApplicationStatus.AnalystName")
                        .Append("FROM NZTR_ApplicationStatus")
                        .Append("WHERE Archived = 0");   
                }
            }
        }
    }
    

    Any ideas ?

    Cheers, Nigel

  • Comment author was deleted

    Aug 22, 2016 @ 07:09

    ARe you sure about the tablename? Tried setting a breakpoint on the if?

    Cheers, Tim

  • Comment author was deleted

    Aug 22, 2016 @ 07:58

    Could you try the following, since if it's only limiting you want to do you only need to set the where https://github.com/TimGeyssens/UIOMatic/blob/master/src/Example/Startup.cs#L40

  • Nigel Wilson 944 posts 2076 karma points
    Aug 22, 2016 @ 20:21
    Nigel Wilson
    0

    Hi Tim

    Have tried setting a break point on the if statement but it isn't getting hit - very weird.

    If I put a break point on the line of code within the ApplicationStarted method that gets hit, but I cannot step into the individual method - it simply steps out of the ApplicationStarted method.

    Weird...

    Nigel

Please Sign in or register to post replies

Write your reply to:

Draft