-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExampleReference.cs
More file actions
85 lines (69 loc) · 2.48 KB
/
ExampleReference.cs
File metadata and controls
85 lines (69 loc) · 2.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
using System;
using System.Collections.Generic;
using Microsoft.WindowsAzure.StorageClient;
using JoshCodes.Persistence.Azure.Storage;
namespace JoshCodes.Persistence.Azure.Storage.Testing.Unit
{
class ExampleReference : AzureObjectWrapper<ExampleReference.Entity>, IDefineExample
{
public ExampleReference(ExampleReference.Entity entity, CloudTableClient tableClient)
: base(entity, tableClient, "ExampleReferenceTable")
{
}
public Example Example
{
get
{
var example = new ExampleStore(_tableClient).GetReferencedObject(Storage.GetExampleIdRef());
return example;
}
}
public class Entity : Storage.Entity
{
public string ExampleIdRef { get; set; }
public Entity()
{
}
public Entity(AzureObjectReference exampleIdRef, Guid key, DateTime lastModified)
: base(key, lastModified)
{
ExampleIdRef = Encode(exampleIdRef);
}
public AzureObjectReference GetExampleIdRef()
{
return Decode<AzureObjectReference>(this.ExampleIdRef);
}
}
public class Store : AzureObjectStore<IDefineExample, ExampleReference, Entity>
{
public Store(CloudTableClient tableClient)
: base(tableClient, "ExampleReferenceTable")
{
}
public ExampleReference Create(Example example)
{
var idExample = example.GetAzureObjectReference<Example.Entity>();
var entity = new ExampleReference.Entity(idExample, Guid.NewGuid(), DateTime.Now);
Create(entity);
return new ExampleReference(entity, _tableClient);
}
protected override ExampleReference CreateObjectStore(Entity entity)
{
return new ExampleReference(entity, _tableClient);
}
internal IEnumerable<ExampleReference> FindByExample(Example example)
{
var results = QueryOn<Example.Entity>(example, (entity) => entity.ExampleIdRef);
return results;
}
}
public DateTime UpdatedAt
{
get { throw new NotImplementedException(); }
}
public DateTime CreatedAt
{
get { throw new NotImplementedException(); }
}
}
}