Giter Site home page Giter Site logo

Comments (4)

alirezanet avatar alirezanet commented on May 23, 2024 1

Hi,
So If I understand correctly you want something like the bellow output?

SELECT *
FROM [Users] AS [u]
ORDER BY CASE
    WHEN [u].[CreateDate] IS NOT NULL THEN CAST(1 AS bit)
    ELSE CAST(0 AS bit)
END DESC, [u].[CreateDate]

that comes from

var expected = _dbContext.Users
        .OrderByDescending(q => q.CreateDate.HasValue)
        .ThenBy(w => w.CreateDate).ToQueryString();

I'll do a little investigation about this soon.

from gridify.

alirezanet avatar alirezanet commented on May 23, 2024 1

A temporary workaround could be combining the gridify query with a static LINQ :

e.g

   [Fact]
   public void OrderBy_NullableValues()
   {
      // Arrange
      var expected = _dbContext.Users.OrderByDescending(q => q.CreateDate.HasValue).ThenBy(w => w.CreateDate).ToQueryString();
      var gq = new GridifyQuery() {OrderBy = "CreateDate"};

      // Act
      var actual = _dbContext.Users
                     .OrderByDescending(q => q.CreateDate.HasValue)
                     .ApplyOrdering(gq, startWithThenBy: true).ToQueryString();

      // Assert
      Assert.Equal(expected,actual);
   }

you can hard code this part .OrderByDescending(q => q.CreateDate.HasValue) using LINQ and use startWithThenBy parameter to add your dynamic ordering.

from gridify.

alirezanet avatar alirezanet commented on May 23, 2024 1

This feature added in v2.7.0 (Docs):
for achive the bellow query :

query.OrderByDescending(p => p.OrderDate.HasValue).ThenBy(p => p.OrderDate)

you can use the ? character after OrderDate:

query.ApplyOrdering("OrderDate? desc,  OrderDate")

from gridify.

reisi-h avatar reisi-h commented on May 23, 2024 1

Dear Mr Sabouri
I just say Thanks you very very much for your rapid respond and add this feature to this package.
آقا دم شوما گرم

from gridify.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.