Code Monkey home page Code Monkey logo

Comments (6)

acupofjose avatar acupofjose commented on May 18, 2024 1

If that works I’ll push it into the next version for you!

from postgrest-csharp.

acupofjose avatar acupofjose commented on May 18, 2024 1

Available in v2.1.0!

from postgrest-csharp.

acupofjose avatar acupofjose commented on May 18, 2024

You mean something like this?

var supabotMessages = await client.Table<Message>().Filter("id", Postgrest.Constants.Operator.Equals, id).Get();

from postgrest-csharp.

warflash avatar warflash commented on May 18, 2024

Well sort of yeah. Just without the verbosity of "id", Postgrest.Constants.Operator.Equals, id.
The primary keys are already annotated so I was hoping there would be a way to skip the verbose filter statements. For multi col keys in particular it's quite the hassle to create dicts and stuff.

 [Table("my_model")]
    public class MyModel: BaseModel
    {
        [PrimaryKey("id_2")]
        public string Id1 { get; set; }

        [PrimaryKey("id_2")]
        public string Id2{ get; set; }

        [PrimaryKey("id_3")]
        public string Id3 { get; set; }

        [Column("my_col")]
        public short MyCol{ get; set; }
       //....
   }

would result in a query like:

var filters = new Dictionary<string, string>()
           {
                {"id_1", localModel.Id1 },
                {"id_2", localModel.Id2 },
                {"id_3", localModel.Id3 },
            };
var dbModel = postgrestClient.Table<MyModel>().Match(filters).Get();

where to me it feels like the dict creation part should be able to be created automatically based on the [PrimaryKey(xx)] annotations.

Hope that makes sense :D

from postgrest-csharp.

acupofjose avatar acupofjose commented on May 18, 2024

Oh yes! Very nice.

I've added the following on the master branch.

var moviePerson = new MoviePerson { Id = 1, MovieId = 1, PersonId = 1 };
var findMoviePerson = await client.Table<MoviePerson>().Match(moviePerson).Single();

Is that better? (This tangentially required better supporting composite primary keys, which is appreciated!)

from postgrest-csharp.

warflash avatar warflash commented on May 18, 2024

Awesome, yeah the syntax looks very nice, thank you👌

from postgrest-csharp.

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.