Copied to clipboard

Flag this post as spam?

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


  • Erik 11 posts 47 karma points
    May 03, 2016 @ 09:19
    Erik
    0

    UI-O-Matic custum sql query

    Hi.

    Is there a option to inject a custom SQL query to UI-O-Matic. I need to create a dedicated view for some data, that is Date centric and it groups many records.

    Thank you!

  • Comment author was deleted

    May 03, 2016 @ 09:22

    Yup that's possible, you can use the event model for that and basically override the query , this should get you started http://www.nibble.be/?p=493, https://github.com/TimGeyssens/UIOMatic/blob/master/src/Example/Startup.cs

  • Erik 11 posts 47 karma points
    May 03, 2016 @ 09:42
    Erik
    0

    That's looks great.

    Thank you!

  • Erik 11 posts 47 karma points
    May 03, 2016 @ 10:57
    Erik
    0

    Hi.

    I did implement as suggested. But I have a problem with pagination I guess.

    SQL Server does return 164 record, but with the same query in UI-O-Matic I do get back only 40 record (4pages)

    Any idea?

       UIOMatic.Controllers.PetaPocoObjectController.BuildedQuery += SendSatateLogFilteredHelper.CreatedQuery;
    

    And the method.

    public static void CreatedQuery(object sender, QueryEventArgs e)
            {
                if (e.CurrentType == typeof(SendSatateLogFiltered))
                {
                    e.Query = new Sql(@"
    
                    SELECT *
                    FROM [mSendStateLog] as i1
                    inner join (
                    SELECT MAX([ID]) as mId
                        FROM [mSendStateLog] as i1
                        where i1.Created > @0
                        group by [MM]
                        having MAX(cast(Synced as int)) = 0
                        ) as i3
                    on i1.ID = i3.mId
                  ", DateTime.Now.ToString("yyyy-MM-dd"));
                }
            }
    
Please Sign in or register to post replies

Write your reply to:

Draft