Created
September 2, 2016 15:06
-
-
Save mythz/37c08eed541dd11f20e72bf1e3657c01 to your computer and use it in GitHub Desktop.
PocoDynamo HashKey Query
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Linq; | |
using Amazon; | |
using Amazon.DynamoDBv2; | |
using ServiceStack; | |
using ServiceStack.Text; | |
using ServiceStack.Aws.DynamoDb; | |
using ServiceStack.DataAnnotations; | |
var awsDb = new AmazonDynamoDBClient("keyId","key",new AmazonDynamoDBConfig { ServiceURL="http://localhost:8000"}); | |
var db = new PocoDynamo(awsDb); | |
public class MyClass | |
{ | |
public string Id { get; set; } | |
public string RangeKey { get; set; } | |
public string Content { get; set; } | |
} | |
db.RegisterTable<MyClass>(); | |
db.DeleteTable<MyClass>(); // Delete existing MyClass Table (if any) | |
db.InitSchema(); // Creates MyClass DynamoDB Table | |
var items = 5.Times(i => new MyClass { | |
Id = $"hashkey{i % 2}", RangeKey = $"rangekey{i}", Content = $"Content {i}" }); | |
db.PutItems(items); | |
var rows = db.FromQuery<MyClass>(x => x.Id == "hashkey1").Exec().ToArray(); | |
rows.PrintDump(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<packages> | |
<package id="AWSSDK.Core" version="3.1.9.1" targetFramework="net45" /> | |
<package id="AWSSDK.DynamoDBv2" version="3.1.5.2" targetFramework="net45" /> | |
<package id="AWSSDK.S3" version="3.1.8.1" targetFramework="net45" /> | |
<package id="AWSSDK.SQS" version="3.1.0.12" targetFramework="net45" /> | |
<package id="ServiceStack.Text" version="4.5.0" targetFramework="net45" /> | |
<package id="ServiceStack.Client" version="4.5.0" targetFramework="net45" /> | |
<package id="ServiceStack.Interfaces" version="4.5.0" targetFramework="net45" /> | |
<package id="ServiceStack.Common" version="4.5.0" targetFramework="net45" /> | |
<package id="ServiceStack" version="4.5.0" targetFramework="net45" /> | |
<package id="ServiceStack.Aws" version="4.5.0" targetFramework="net45" /> | |
</packages> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment