Code Monkey home page Code Monkey logo

Comments (8)

alirezanet avatar alirezanet commented on August 16, 2024 1

Hi, Thank you for the feedback.
I fixed this issue, can you confirm is this the behavior you expected?
e.g:

      [Fact] // issue #27
      public void ApplyFiltering_GreaterThanOrEqualBetweenTwoStrings() 
      {
         var actual = _fakeRepository.AsQueryable().ApplyFiltering("name >= c" ).ToList();
         var expected = _fakeRepository.Where(q => string.Compare(q.Name, "c", StringComparison.Ordinal ) >= 0  ).ToList();
         
         Assert.Equal(expected.Count, actual.Count);
         Assert.Equal(expected, actual);
         Assert.True(actual.Any());
      }

other tests.

Also, it will be released in the next minor version.

from gridify.

VahidN avatar VahidN commented on August 16, 2024 1

Thanks. EF-Core doesn't like the third parameter here!
It translates

var res = query.Where(q => string.Compare(q.Name, "c") >= 0).ToList();

To:

 SELECT [g].[Id], [g].[Name]
      FROM [Genres] AS [g]
      WHERE [g].[Name] >= N'c'

But it can't translate the query when StringComparison.xyz is specified:

var res = query.Where(q => string.Compare(q.Name, "c", StringComparison.Ordinal) >= 0).ToList();

Result:

      An unhandled exception has occurred while executing the request.
      System.InvalidOperationException: The LINQ expression 'DbSet<Genre>()
          .Where(g => string.Compare(
              strA: g.Name,
              strB: "c",
              comparisonType: Ordinal) >= 0)' could not be translated.

from gridify.

alirezanet avatar alirezanet commented on August 16, 2024 1

This feature is available in version v2.2.0.
if you want to use this feature in SqlServer or MySql providers alongside with EntitiyFramework you should enable the compatibility layer from the Gridify.EntityFramework package.

e.g

  // You should use this configuration in your startup class or main method.
  GridifyGlobalConfiguration.EnableEntityFrameworkCompatibilityLayer();

from gridify.

alirezanet avatar alirezanet commented on August 16, 2024

The translating to SQL query part is the problem. by default, we should always use the third parameter according to Microsoft documentation because Gridify is not limited to EntityFramework, but for compatibility, I'll probably add a global method EnableEntityFrameworkCompatibilityLayer in the Gridify.EntityFramework package to make underlying functions compatible to EntityFramework.

from gridify.

VahidN avatar VahidN commented on August 16, 2024

Thanks. Make this property public. Maybe someone just wants to use the original package.

from gridify.

alirezanet avatar alirezanet commented on August 16, 2024

Thanks. Make this property public. Maybe someone just wants to use the original package.

You're welcome., thank you for the feedback.
I really thought about this, there is nothing related to EntityFramework in the Gridify package, if I make this property public we really don't need the GridifyGlobalConfiguration class. I chose the harder way to keep the SoC. Also, if users using gridify alongside EF they should install the Gridify.EntityFramework package in the first place. but To be honest I'm not really sure this is a good solution or not yet. what is your opinion? having EntityFramework related configuration in the gridify package doesn't violate the SoC?

from gridify.

VahidN avatar VahidN commented on August 16, 2024

Or you can just simply add it here:

var gQuery = new GridifyQuery()
{
    // ...

    IsEntityFrameworkCompatible = true  
};

from gridify.

alirezanet avatar alirezanet commented on August 16, 2024

Thanks. Make this property public. Maybe someone just wants to use the original package.

Hi,
It is public now, check out the docs Here

Thanks for the feedback

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.