Skip to content

Commit 0318214

Browse files
Merge pull request #553 from johelvisguzman/issue552
Fixed compatibility issues with the azure repository context
2 parents 0cc5bfd + 8b518b9 commit 0318214

File tree

64 files changed

+486
-416
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+486
-416
lines changed

benchmarks/DotNetToolkit.Repository.Performance/App.config

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,7 @@
22
<configuration>
33
<connectionStrings>
44
<add name="DefaultConnection" connectionString="Data Source=(LocalDb)\MSSQLLocalDB;Initial Catalog=tempdb;Integrated Security=True;MultipleActiveResultSets=True" providerName="System.Data.SqlClient" />
5+
<add name="AzureStorageBlobConnection" connectionString="DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;BlobEndpoint=http://127.0.0.1:10000/devstoreaccount1;" />
6+
<add name="AzureStorageTableConnection" connectionString="DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;TableEndpoint=http://127.0.0.1:10002/devstoreaccount1;" />
57
</connectionStrings>
68
</configuration>

benchmarks/DotNetToolkit.Repository.Performance/BenchmarkBase.cs

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
namespace DotNetToolkit.Repository.Performance
22
{
33
using AdoNet;
4+
using AzureStorageBlob;
5+
using AzureStorageTable;
46
using BenchmarkDotNet.Attributes;
57
using Configuration.Options;
68
using Data;
@@ -97,6 +99,22 @@ protected IRepositoryOptions BuildOptions(ContextProviderType provider)
9799
builder.UseEntityFrameworkCore<EfCoreDbContext>(x => x.UseSqlServer(ConnectionString));
98100
break;
99101
}
102+
case ContextProviderType.AzureStorageBlob:
103+
{
104+
builder.UseAzureStorageBlob(
105+
nameOrConnectionString: "AzureStorageBlobConnection",
106+
container: Guid.NewGuid().ToString(),
107+
createIfNotExists: true);
108+
break;
109+
}
110+
case ContextProviderType.AzureStorageTable:
111+
{
112+
builder.UseAzureStorageTable(
113+
nameOrConnectionString: "AzureStorageTableConnection",
114+
tableName: "TableName" + Guid.NewGuid().ToString("N").ToUpper(),
115+
createIfNotExists: true);
116+
break;
117+
}
100118
default:
101119
throw new ArgumentOutOfRangeException(nameof(provider));
102120
}
@@ -114,7 +132,9 @@ public virtual IEnumerable<ContextProviderType> Providers()
114132
ContextProviderType.AdoNet,
115133
ContextProviderType.NHibernate,
116134
ContextProviderType.EntityFramework,
117-
ContextProviderType.EntityFrameworkCore
135+
ContextProviderType.EntityFrameworkCore,
136+
ContextProviderType.AzureStorageBlob,
137+
ContextProviderType.AzureStorageTable,
118138
};
119139
}
120140

benchmarks/DotNetToolkit.Repository.Performance/Benchmarks.Repository.Add.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public void Setup()
1414
{
1515
BaseSetup();
1616

17-
_customer = new Customer { Name = "Random Name" };
17+
_customer = new Customer { Id = new System.Random().Next(), Name = "Random Name" };
1818

1919
_repo = new Repository<Customer>(BuildOptions(Provider));
2020
}

benchmarks/DotNetToolkit.Repository.Performance/Benchmarks.Repository.Delete.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public void Setup()
1414
{
1515
BaseSetup();
1616

17-
_customer = new Customer { Name = "Random Name" };
17+
_customer = new Customer { Id = new System.Random().Next(), Name = "Random Name" };
1818

1919
_repo = new Repository<Customer>(BuildOptions(Provider));
2020
_repo.Add(_customer);

benchmarks/DotNetToolkit.Repository.Performance/Benchmarks.Repository.Find.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public void Setup()
2222

2323
_pagingOptions = _defaultOptions.Page(1, 10);
2424

25-
_customer = new Customer { Name = "Random Name" };
25+
_customer = new Customer { Id = new System.Random().Next(), Name = "Random Name" };
2626

2727
_repo = new Repository<Customer>(BuildOptions(Provider));
2828
_repo.Add(_customer);

benchmarks/DotNetToolkit.Repository.Performance/Benchmarks.Repository.GroupBy.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public void Setup()
2222

2323
_pagingOptions = _defaultOptions.Page(1, 10);
2424

25-
_customer = new Customer { Name = "Random Name" };
25+
_customer = new Customer { Id = new System.Random().Next(), Name = "Random Name" };
2626

2727
_repo = new Repository<Customer>(BuildOptions(Provider));
2828
_repo.Add(_customer);

benchmarks/DotNetToolkit.Repository.Performance/Benchmarks.Repository.ToDictionary.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public void Setup()
2222

2323
_pagingOptions = _defaultOptions.Page(1, 10);
2424

25-
_customer = new Customer { Name = "Random Name" };
25+
_customer = new Customer { Id = new System.Random().Next(), Name = "Random Name" };
2626

2727
_repo = new Repository<Customer>(BuildOptions(Provider));
2828
_repo.Add(_customer);

benchmarks/DotNetToolkit.Repository.Performance/Benchmarks.Repository.Update.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public void Setup()
1414
{
1515
BaseSetup();
1616

17-
_customer = new Customer { Name = "Random Name" };
17+
_customer = new Customer { Id = new System.Random().Next(), Name = "Random Name" };
1818

1919
_repo = new Repository<Customer>(BuildOptions(Provider));
2020
_repo.Add(_customer);

benchmarks/DotNetToolkit.Repository.Performance/Data/ContextProviderType.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,7 @@ public enum ContextProviderType
99
NHibernate,
1010
EntityFramework,
1111
EntityFrameworkCore,
12+
AzureStorageBlob,
13+
AzureStorageTable,
1214
}
1315
}
Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,35 @@
11
namespace DotNetToolkit.Repository.Performance.Data
22
{
3+
using System;
34
using System.ComponentModel.DataAnnotations;
5+
using System.ComponentModel.DataAnnotations.Schema;
46

5-
public class Customer
7+
public class Customer : Microsoft.WindowsAzure.Storage.Table.TableEntity
68
{
7-
public int Id { get; set; }
8-
[Required]
9+
private int _id;
10+
11+
[Key]
12+
[DatabaseGenerated(DatabaseGeneratedOption.None)]
13+
public int Id
14+
{
15+
get { return _id; }
16+
set
17+
{
18+
_id = value;
19+
RowKey = _id.ToString();
20+
}
21+
}
922
public string Name { get; set; }
23+
24+
// for azure table compability (do not map since they are not realted to sql tests)
25+
[NotMapped]
26+
public new DateTimeOffset Timestamp { get; set; }
27+
[NotMapped]
28+
public new string ETag { get; set; }
29+
30+
public Customer()
31+
{
32+
PartitionKey = string.Empty;
33+
}
1034
}
1135
}

0 commit comments

Comments
 (0)