Sorting Query

Topics: Writing modules
Jul 31, 2013 at 6:28 PM
Edited Jul 31, 2013 at 6:32 PM
I have an issue setting up the proper sorting for a query I have. I created a binding and am sorting by my date field.

The following data is returned:
5/31/2013
5/28/2013
5/24/2013
5/21/2013
5/17/2013
5/14/2013
5/10/2013
5/7/2013
5/3/2013
6/28/2013
6/25/2013
6/21/2013
6/18/2013
6/14/2013
6/11/2013
6/7/2013
6/4/2013
7/23/2013
7/19/2013
7/16/2013
As you can see they are sorted, but not by the date.

How can enable the proper date sorting?

TIA,

Steve
Coordinator
Jul 31, 2013 at 8:01 PM
Can you give more details about how exactly you set-up the field and the query?
Jul 31, 2013 at 8:17 PM
I create the Content Type using the following:
            ContentDefinitionManager.AlterTypeDefinition("MyObject", builder =>
                builder
                    .Creatable()
                    .WithPart("CommonPart")
                    .WithPart("TitlePart")
                    .WithPart("AutoroutePart", part =>
                        part
                        .WithSetting("AutorouteSettings.AllowCustomPattern", "true")
                        .WithSetting("AutorouteSettings.AutomaticAdjustmentOnEdit", "false")
                        .WithSetting("AutorouteSettings.PatternDefinitions", "[{Name:'Winning Numbers Title', Pattern: 'winning-numbers/{Content.Slug}', Description: 'winning-numbers/winning-numbers-title'},{Name:'Winning Numbers Title', Pattern:'winning-numbers/{Content.Slug}', Description:'winning-numbers/winning-numbers-title'}]")
                        .WithSetting("AutorouteSettings.DefaultPatternIndex", "0")
                        ));
            
            SchemaBuilder.CreateTable("MyObjectPartRecord", table => table
                .ContentPartRecord()
                .Column<string>("DrawDate")
                .Column<string>("Name"));

            ContentDefinitionManager.AlterTypeDefinition("MyObject", builder => builder.WithPart("MyObjectPart"));
            ContentDefinitionManager.AlterPartDefinition("MyObjectPart", builder => builder.Attachable());
I then created a Binding use the DrawDate column. Then I created a query that sorted by this column.

Does that help?

Thanks!
Coordinator
Jul 31, 2013 at 8:22 PM
Is DrawDate what you are trying to sort on? That's a string, not a DateTime.
Jul 31, 2013 at 8:55 PM
Well that would make sense, wouldn't it... Good catch!!!

Thanks!