GithubHelp home page GithubHelp logo

Comments (3)

mysticmind avatar mysticmind commented on July 27, 2024

Query for a single document should work fine. What is the value of slug which you are searching and the entry in db? It would help for you to provide some code with data for us to check.

from marten.

johnholliday avatar johnholliday commented on July 27, 2024

This is the method:

    public async Task<Template?> GetBySlugAsync(string slug)
    {
        var templates = await _session.Query<Template>().ToListAsync();
        if (templates != null) foreach (var item in templates) if (item.Slug == slug) return item;
        // return await _session.Query<Template>().Where(x => x.Slug == slug).SingleOrDefaultAsync();
        return default;
    }

This is value of "slug" that is being passed to the method:

var slug = "my-document-template";

This is the entry in the database:

{
  "id": "57b5239b-171d-4200-9bd2-ed7951d76e72",
  "title": "My Document Template",
  "slug": "my-document-template",
  "description": "a brief Document description",
  "tags": [
    "first tag",
    "another tag"
  ]
}

Retrieving the entire list and then matching on the slug returns the correct database entry.
Querying for a single document returns null.

from marten.

jeremydmiller avatar jeremydmiller commented on July 27, 2024

@johnholliday Hey, check your JSON settings in Marten. Notice that "slug" is I'm guessing camel casing in your database. Are you explicitly setting your JSON casing to CamelCase with Marten?

I'm moving this to a discussion, because it's extremely unlikely that this is anything but the JSON serialization settings.

from marten.

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.