Code Monkey home page Code Monkey logo

Comments (3)

danny-zegel-zocdoc avatar danny-zegel-zocdoc commented on June 28, 2024 1

no i had trouble with regular records but I wrote them with constructor properties like this

[DynamoDBTable("actors", lowerCamelCaseProperties:true)]
public record ActorRole(
    [property: DynamoDBHashKey("actor")] string Name,
    string Movie,
    string Role,
    DateTime LastUpdated);

from aws-sdk-net.

ashishdhingra avatar ashishdhingra commented on June 28, 2024

Per Create record types, Records are types that use value-based equality. This is opposite of class types which use reference based equality. Unsure if record types would fit into object based model. Needs review with the team.

from aws-sdk-net.

ashovlin avatar ashovlin commented on June 28, 2024

Is it record struct support that you're interested in? I do see those getting stopped in our CanInstantiateHelper:

private static bool CanInstantiateHelper(Type objectType, Type[][] validConstructorInputs)


This seemed to work for me for record class, though didn't test exhaustively.

    [DynamoDBTable("actors", lowerCamelCaseProperties:true)]
    public record class ActorRole
    {
        [DynamoDBHashKey("actor")]
        public string Name { get; set; }

        public string Movie { get; set; }

        public string Role { get; set; }

        public DateTime LastUpdated { get; set; }
    }

    static async Task Main(string[] args)
    {
        var client = new AmazonDynamoDBClient();
        IDynamoDBContext context = new DynamoDBContext(client);

        var actor = await context.LoadAsync<ActorRole>("Tom Hanks", "Toy Story");
        Console.WriteLine(actor.Role);

        actor.LastUpdated = DateTime.UtcNow;
        await context.SaveAsync(actor);

        var document = context.ToDocument<ActorRole>(actor);
        foreach (var value in document)
        {
            Console.WriteLine(value.Key + " " + value.Value);
        }

        var query = context.QueryAsync<ActorRole>("Tom Hanks");

        foreach (var item in await query.GetRemainingAsync())
        {
            Console.WriteLine(item.Name + " " + item.Movie + " " + item.LastUpdated);
        }
    }

from aws-sdk-net.

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.