Code Monkey home page Code Monkey logo

Comments (6)

vklymchuk avatar vklymchuk commented on August 16, 2024 1

Here is a simple solution. In the console app I execute one method from RecipientService twice. Please specify your connection string or change to what you need in OMS.Entity -> Context -> OMSContext file and update a db with Initial migration.

from gridify.

alirezanet avatar alirezanet commented on August 16, 2024 1

This error is related to the Entity Framework Service Provider Caching system. I will investigate more on this to find out why this is happening and what is the best way to handle similar cases. Until then you can disable service provider caching.

      protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        {
            //optionsBuilder.UseInMemoryDatabase("mydb");
            optionsBuilder.EnableServiceProviderCaching(false);
        }

from gridify.

alirezanet avatar alirezanet commented on August 16, 2024 1

@vklymchuk
I've added EntityFramework ServiceProviderCaching support to Gridify. you can use this feature in the next release. (1.3.2)
thank you.

from gridify.

alirezanet avatar alirezanet commented on August 16, 2024

Hello
your first problem is not clear because you can use a field name multiple times.
you need to provide more information to help reproduce the problem.

      [Fact]
      public void ApplyFiltering_DuplicateFiledName()
      {
         var gq = new GridifyQuery {Filter = "name==John|name==Sara"};
         var actual = _fakeRepository.AsQueryable()
            .ApplyFiltering(gq)
            .ToList();
         var expected = _fakeRepository.Where(q => q.Name == "John" | q.Name == "Sara").ToList();
         Assert.Equal(expected.Count, actual.Count);
         Assert.Equal(expected, actual);
         Assert.True(actual.Any());
      }

there is no problem with duplicate field names.


but about your second question about null:
by default, Gridify does not have any magic string to handle null strings yet but you can define it if you need.
you need to create a custom mapping (GridifyMapper) and implement your own null handling.
e.g look at this test:

      [Fact]
      public void ApplyFiltering_NullQuery()
      {
         // create custom mapper
         var gm = new GridifyMapper<TestClass>().GenerateMappings();

         // map any string to related property , also use Client convertor to handle custom scenarios
         gm.AddMap("date", g => g.MyDateTime, q => q == "null" ? null : q);

         var gq = new GridifyQuery {Filter = "date==null"};

         var actual = _fakeRepository.AsQueryable()
            .ApplyFiltering(gq, gm)
            .ToList();

         var expected = _fakeRepository.Where(q => q.MyDateTime == null).ToList();
         Assert.Equal(expected.Count, actual.Count);
         Assert.Equal(expected, actual);
         Assert.True(actual.Any());
      }

from gridify.

vklymchuk avatar vklymchuk commented on August 16, 2024

you need to create a custom mapping (GridifyMapper) and implement your own null handling.

Thanks, implemented.

you need to provide more information to help reproduce the problem.

Try to repeat filtering with the same filter query please. I noticed it'd occured when I send one request to api twice or more.

from gridify.

alirezanet avatar alirezanet commented on August 16, 2024

your welcome.
I think your problem is not related to Gridify because internally Gridify is not using any Dictionary at all.
look at the second line of your error message:

System.ArgumentException: An item with the same key has already been added. Key: Param_0
   at System.Collections.Generic.Dictionary`2.TryInsert(TKey key, TValue value, InsertionBehavior behavior)

it can not add some Keys to some dictionary... I'm 90 percent sure it is not a Gridify problem because I can't find any errors in my tests.
but try to create a small repo to reproduce the problem, I will check.

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.