Skip to content

Commit 832ff49

Browse files
committed
Merge remote-tracking branch 'origin/dev' into mogah-prototype
2 parents 30ba138 + 78e88f9 commit 832ff49

32 files changed

Lines changed: 487 additions & 186 deletions

src/DatabaseMigrationTools/DatabaseMigrationTools.csproj

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,6 @@
5454
<None Include="App.config" />
5555
</ItemGroup>
5656
<ItemGroup>
57-
<PackageReference Include="Autofac.Extensions.DependencyInjection">
58-
<Version>4.2.0</Version>
59-
</PackageReference>
6057
<PackageReference Include="EntityFramework">
6158
<Version>6.2.0</Version>
6259
</PackageReference>
@@ -65,15 +62,6 @@
6562
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
6663
<PrivateAssets>all</PrivateAssets>
6764
</PackageReference>
68-
<PackageReference Include="Microsoft.Extensions.Configuration">
69-
<Version>1.1.2</Version>
70-
</PackageReference>
71-
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions">
72-
<Version>1.1.2</Version>
73-
</PackageReference>
74-
<PackageReference Include="Microsoft.Extensions.Configuration.Binder">
75-
<Version>1.1.2</Version>
76-
</PackageReference>
7765
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables">
7866
<Version>1.1.2</Version>
7967
</PackageReference>
@@ -83,23 +71,17 @@
8371
<PackageReference Include="Microsoft.Extensions.Configuration.Json">
8472
<Version>1.1.2</Version>
8573
</PackageReference>
86-
<PackageReference Include="Microsoft.Extensions.Logging">
87-
<Version>1.0.0</Version>
88-
</PackageReference>
89-
<PackageReference Include="Microsoft.Extensions.Options">
90-
<Version>1.1.2</Version>
91-
</PackageReference>
9274
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions">
9375
<Version>1.1.2</Version>
9476
</PackageReference>
9577
<PackageReference Include="NuGet.Jobs.Common">
9678
<Version>4.1.0-master-2602271</Version>
9779
</PackageReference>
9880
<PackageReference Include="NuGet.Services.Configuration">
99-
<Version>2.49.0</Version>
81+
<Version>2.50.0</Version>
10082
</PackageReference>
10183
<PackageReference Include="NuGet.Services.Validation">
102-
<Version>2.49.0</Version>
84+
<Version>2.50.0</Version>
10385
</PackageReference>
10486
</ItemGroup>
10587
<ItemGroup>

src/GalleryTools/GalleryTools.csproj

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,6 @@
8686
<PackageReference Include="Microsoft.Extensions.CommandLineUtils">
8787
<Version>1.1.1</Version>
8888
</PackageReference>
89-
<PackageReference Include="Newtonsoft.Json">
90-
<Version>9.0.1</Version>
91-
</PackageReference>
9289
<PackageReference Include="System.ValueTuple">
9390
<Version>4.5.0</Version>
9491
</PackageReference>

src/NuGet.Services.DatabaseMigration/NuGet.Services.DatabaseMigration.csproj

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@
4848
<Reference Include="System.Data.DataSetExtensions" />
4949
<Reference Include="Microsoft.CSharp" />
5050
<Reference Include="System.Data" />
51-
<Reference Include="System.Net.Http" />
5251
<Reference Include="System.Xml" />
5352
</ItemGroup>
5453
<ItemGroup>
@@ -109,7 +108,7 @@
109108
<Version>4.1.0-master-2602271</Version>
110109
</PackageReference>
111110
<PackageReference Include="NuGet.Services.Configuration">
112-
<Version>2.49.0</Version>
111+
<Version>2.50.0</Version>
113112
</PackageReference>
114113
</ItemGroup>
115114
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />

src/NuGetGallery.Core/Entities/EntitiesContext.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public EntitiesContext(string connectionString, bool readOnly)
5353
public EntitiesContext(DbConnection connection, bool readOnly)
5454
: base(connection, contextOwnsConnection: true)
5555
{
56-
ReadOnly = readOnly;
56+
ReadOnly = readOnly;
5757
}
5858

5959
public bool ReadOnly { get; private set; }
@@ -73,7 +73,7 @@ public EntitiesContext(DbConnection connection, bool readOnly)
7373
/// </summary>
7474
public DbSet<User> Users { get; set; }
7575

76-
DbSet<T> IEntitiesContext.Set<T>()
76+
DbSet<T> IReadOnlyEntitiesContext.Set<T>()
7777
{
7878
return base.Set<T>();
7979
}
Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
11
// Copyright (c) .NET Foundation. All rights reserved.
22
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
33

4-
using System;
54
using System.Data.Entity;
65
using System.Threading.Tasks;
76
using NuGet.Services.Entities;
87

98
namespace NuGetGallery
109
{
11-
public interface IEntitiesContext : IDisposable
10+
public interface IEntitiesContext : IReadOnlyEntitiesContext
1211
{
1312
DbSet<Certificate> Certificates { get; set; }
14-
DbSet<Package> Packages { get; set; }
1513
DbSet<PackageDeprecation> Deprecations { get; set; }
1614
DbSet<PackageRegistration> PackageRegistrations { get; set; }
1715
DbSet<Credential> Credentials { get; set; }
@@ -23,9 +21,7 @@ public interface IEntitiesContext : IDisposable
2321
DbSet<SymbolPackage> SymbolPackages { get; set; }
2422

2523
Task<int> SaveChangesAsync();
26-
DbSet<T> Set<T>() where T : class;
2724
void DeleteOnCommit<T>(T entity) where T : class;
28-
void SetCommandTimeout(int? seconds);
2925
IDatabase GetDatabase();
3026
}
3127
}

src/NuGetGallery.Core/Entities/IEntityRepository.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,17 @@
22
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
33

44
using System.Collections.Generic;
5-
using System.Linq;
65
using System.Threading.Tasks;
76

87
namespace NuGetGallery
98
{
10-
public interface IEntityRepository<T>
9+
public interface IEntityRepository<T> : IReadOnlyEntityRepository<T>
1110
where T : class, new()
1211
{
1312
Task CommitChangesAsync();
1413
void InsertOnCommit(T entity);
1514
void InsertOnCommit(IEnumerable<T> entities);
1615
void DeleteOnCommit(T entity);
1716
void DeleteOnCommit(IEnumerable<T> entities);
18-
IQueryable<T> GetAll();
1917
}
2018
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Copyright (c) .NET Foundation. All rights reserved.
2+
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3+
4+
using System;
5+
using System.Data.Entity;
6+
using NuGet.Services.Entities;
7+
8+
namespace NuGetGallery
9+
{
10+
public interface IReadOnlyEntitiesContext : IDisposable
11+
{
12+
DbSet<Package> Packages { get; set; }
13+
14+
DbSet<T> Set<T>() where T : class;
15+
16+
void SetCommandTimeout(int? seconds);
17+
}
18+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Copyright (c) .NET Foundation. All rights reserved.
2+
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3+
4+
using System.Linq;
5+
6+
namespace NuGetGallery
7+
{
8+
public interface IReadOnlyEntityRepository<T>
9+
where T : class, new()
10+
{
11+
IQueryable<T> GetAll();
12+
}
13+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
// Copyright (c) .NET Foundation. All rights reserved.
2+
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3+
4+
using System;
5+
using System.Data.Common;
6+
using System.Data.Entity;
7+
using System.Linq;
8+
using NuGet.Services.Entities;
9+
10+
namespace NuGetGallery
11+
{
12+
public class ReadOnlyEntitiesContext : IReadOnlyEntitiesContext
13+
{
14+
private readonly EntitiesContext _entitiesContext;
15+
16+
public ReadOnlyEntitiesContext(DbConnection connection)
17+
{
18+
_entitiesContext = new EntitiesContext(connection, readOnly: true);
19+
}
20+
21+
public DbSet<Package> Packages
22+
{
23+
get
24+
{
25+
return _entitiesContext.Packages;
26+
}
27+
set
28+
{
29+
_entitiesContext.Packages = value;
30+
}
31+
}
32+
33+
DbSet<T> IReadOnlyEntitiesContext.Set<T>()
34+
{
35+
return _entitiesContext.Set<T>();
36+
}
37+
38+
public void SetCommandTimeout(int? seconds)
39+
{
40+
_entitiesContext.SetCommandTimeout(seconds);
41+
}
42+
43+
public void Dispose()
44+
{
45+
_entitiesContext.Dispose();
46+
}
47+
}
48+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// Copyright (c) .NET Foundation. All rights reserved.
2+
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3+
4+
using System.Linq;
5+
6+
namespace NuGetGallery
7+
{
8+
public class ReadOnlyEntityRepository<T> : IReadOnlyEntityRepository<T>
9+
where T : class, new()
10+
{
11+
private readonly IReadOnlyEntitiesContext _readOnlyEntitiesContext;
12+
13+
public ReadOnlyEntityRepository(IReadOnlyEntitiesContext readOnlyEntitiesContext)
14+
{
15+
_readOnlyEntitiesContext = readOnlyEntitiesContext;
16+
}
17+
18+
public IQueryable<T> GetAll()
19+
{
20+
return _readOnlyEntitiesContext.Set<T>();
21+
}
22+
}
23+
}

0 commit comments

Comments
 (0)