Skip to content
This repository was archived by the owner on Jul 24, 2022. It is now read-only.

Commit baeedc2

Browse files
committed
编译通过
1 parent d17eb31 commit baeedc2

17 files changed

+299
-292
lines changed

src/EFCore.MongoDB/EFCore.MongoDB.csproj

+6-4
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
<Using Include="System.Diagnostics" />
1616
<Using Include="System.Linq.Expressions" />
1717
<Using Include="System.Reflection" />
18-
<Using Include="Microsoft.Azure.Cosmos" />
1918
<Using Include="Microsoft.EntityFrameworkCore" />
2019
<Using Include="Microsoft.EntityFrameworkCore.ChangeTracking" />
2120
<Using Include="Microsoft.EntityFrameworkCore.Diagnostics" />
@@ -33,6 +32,7 @@
3332
<Using Include="Microsoft.EntityFrameworkCore.Utilities" />
3433
<Using Include="Microsoft.Extensions.Logging" />
3534
<Using Include="Microsoft.Extensions.DependencyInjection" />
35+
<Using Include="MongoDB.Driver"/>
3636
</ItemGroup>
3737

3838
<ItemGroup>
@@ -42,20 +42,22 @@
4242

4343

4444
<ItemGroup>
45-
<PackageReference Include="Microsoft.Azure.Cosmos" Version="3.24.0" />
4645
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="6.0.2" />
4746
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="6.0.2">
4847
<PrivateAssets>all</PrivateAssets>
4948
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
5049
</PackageReference>
5150
<PackageReference Include="Microsoft.EntityFrameworkCore.Proxies" Version="6.0.2" />
51+
<PackageReference Include="MongoDB.Driver" Version="2.14.1" />
52+
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
53+
<PackageReference Include="Newtonsoft.Json.Bson" Version="1.0.2" />
5254
</ItemGroup>
5355

5456
<ItemGroup>
5557
<Compile Update="Properties\MongoDBStrings.Designer.cs">
5658
<DependentUpon>MongoDBStrings.Designer.tt</DependentUpon>
57-
<DesignTime>True</DesignTime>
58-
<AutoGen>True</AutoGen>
59+
<!--<DesignTime>True</DesignTime>-->
60+
5961
<!--<AutoGen>True</AutoGen>-->
6062
</Compile>
6163
</ItemGroup>

src/EFCore.MongoDB/Extensions/MongoDBDatabaseFacadeExtensions.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ public static class MongoDBDatabaseFacadeExtensions
2121
/// See <see href="https://aka.ms/efcore-docs-MongoDB">Accessing Azure MongoDB DB with EF Core</see> for more information and examples.
2222
/// </remarks>
2323
/// <param name="databaseFacade">The <see cref="DatabaseFacade" /> for the context.</param>
24-
/// <returns>The <see cref="CosmosClient" /></returns>
25-
public static CosmosClient GetMongoDBClient(this DatabaseFacade databaseFacade)
24+
/// <returns>The <see cref="MongoClient" /></returns>
25+
public static MongoClient GetMongoDBClient(this DatabaseFacade databaseFacade)
2626
=> GetService<ISingletonMongoDBClientWrapper>(databaseFacade).Client;
2727

2828
private static TService GetService<TService>(IInfrastructure<IServiceProvider> databaseFacade)

src/EFCore.MongoDB/Extensions/MongoDBEntityTypeBuilderExtensions.cs

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33

44
using IoTSharp.EntityFrameworkCore.MongoDB.Metadata.Internal;
5+
using IoTSharp.EntityFrameworkCore.MongoDB.Storage.Internal;
56

67
// ReSharper disable once CheckNamespace
78
namespace IoTSharp.EntityFrameworkCore.MongoDB.Extensions;

src/EFCore.MongoDB/Extensions/MongoDBEntityTypeExtensions.cs

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33

44
using IoTSharp.EntityFrameworkCore.MongoDB.Metadata.Internal;
5+
using IoTSharp.EntityFrameworkCore.MongoDB.Storage.Internal;
56

67
// ReSharper disable once CheckNamespace
78
namespace IoTSharp.EntityFrameworkCore.MongoDB.Extensions;

src/EFCore.MongoDB/Extensions/MongoDBModelBuilderExtensions.cs

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33

44
using IoTSharp.EntityFrameworkCore.MongoDB.Metadata.Internal;
5+
using IoTSharp.EntityFrameworkCore.MongoDB.Storage.Internal;
56

67
// ReSharper disable once CheckNamespace
78
namespace IoTSharp.EntityFrameworkCore.MongoDB.Extensions;

src/EFCore.MongoDB/Extensions/MongoDBModelExtensions.cs

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33

44
using IoTSharp.EntityFrameworkCore.MongoDB.Metadata.Internal;
5+
using IoTSharp.EntityFrameworkCore.MongoDB.Storage.Internal;
56

67
// ReSharper disable once CheckNamespace
78
namespace IoTSharp.EntityFrameworkCore.MongoDB.Extensions;
+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
4+
using MongoDB.Bson;
5+
6+
namespace IoTSharp.EntityFrameworkCore.MongoDB
7+
{
8+
internal class ItemRequestOptions
9+
{
10+
public BsonValue? IfMatchEtag { get; set; }
11+
public bool EnableContentResponseOnWrite { get; set; }
12+
}
13+
}
+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
4+
using System.Net;
5+
6+
namespace IoTSharp.EntityFrameworkCore.MongoDB
7+
{
8+
public class MongoDBException : Exception
9+
{
10+
public HttpStatusCode StatusCode { get; internal set; }
11+
public TimeSpan? RetryAfter { get; internal set; }
12+
}
13+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
4+
using Newtonsoft.Json.Linq;
5+
6+
namespace IoTSharp.EntityFrameworkCore.MongoDB.Storage.Internal
7+
{
8+
public class FeedIterator : IFindFluent<Newtonsoft.Json.Linq.JObject, Newtonsoft.Json.Linq.JToken>
9+
{
10+
public FilterDefinition<JObject> Filter { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
11+
12+
public FindOptions<JObject, JToken> Options => throw new NotImplementedException();
13+
14+
public IFindFluent<JObject, TResult> As<TResult>(global::MongoDB.Bson.Serialization.IBsonSerializer<TResult> resultSerializer = null)
15+
{
16+
throw new NotImplementedException();
17+
}
18+
19+
public long Count(CancellationToken cancellationToken = default)
20+
{
21+
throw new NotImplementedException();
22+
}
23+
24+
public Task<long> CountAsync(CancellationToken cancellationToken = default)
25+
{
26+
throw new NotImplementedException();
27+
}
28+
29+
public long CountDocuments(CancellationToken cancellationToken = default)
30+
{
31+
throw new NotImplementedException();
32+
}
33+
34+
public Task<long> CountDocumentsAsync(CancellationToken cancellationToken = default)
35+
{
36+
throw new NotImplementedException();
37+
}
38+
39+
public IFindFluent<JObject, JToken> Limit(int? limit)
40+
{
41+
throw new NotImplementedException();
42+
}
43+
44+
public IFindFluent<JObject, TNewProjection> Project<TNewProjection>(ProjectionDefinition<JObject, TNewProjection> projection)
45+
{
46+
throw new NotImplementedException();
47+
}
48+
49+
public IFindFluent<JObject, JToken> Skip(int? skip)
50+
{
51+
throw new NotImplementedException();
52+
}
53+
54+
public IFindFluent<JObject, JToken> Sort(SortDefinition<JObject> sort)
55+
{
56+
throw new NotImplementedException();
57+
}
58+
59+
public IAsyncCursor<JToken> ToCursor(CancellationToken cancellationToken = default)
60+
{
61+
throw new NotImplementedException();
62+
}
63+
64+
public Task<IAsyncCursor<JToken>> ToCursorAsync(CancellationToken cancellationToken = default)
65+
{
66+
throw new NotImplementedException();
67+
}
68+
}
69+
}

src/EFCore.MongoDB/Storage/Internal/ISingletonMongoDBClientWrapper.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,5 @@ public interface ISingletonMongoDBClientWrapper : IDisposable
2323
/// any release. You should only use it directly in your code with extreme caution and knowing that
2424
/// doing so can result in application failures when updating to a new Entity Framework Core release.
2525
/// </summary>
26-
CosmosClient Client { get; }
26+
MongoClient Client { get; }
2727
}

src/EFCore.MongoDB/Storage/Internal/JsonMongoDBSerializer.cs

+47-46
Original file line numberDiff line numberDiff line change
@@ -6,49 +6,50 @@
66

77
namespace IoTSharp.EntityFrameworkCore.MongoDB.Storage.Internal;
88

9-
/// <summary>
10-
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
11-
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
12-
/// any release. You should only use it directly in your code with extreme caution and knowing that
13-
/// doing so can result in application failures when updating to a new Entity Framework Core release.
14-
/// </summary>
15-
public class JsonCosmosDBSerializer : CosmosSerializer
16-
{
17-
private static readonly Encoding DefaultEncoding = new UTF8Encoding(false, true);
18-
19-
/// <inheritdoc />
20-
public override T FromStream<T>(Stream stream)
21-
{
22-
using (stream)
23-
{
24-
if (typeof(Stream).IsAssignableFrom(typeof(T)))
25-
{
26-
return (T)(object)stream;
27-
}
28-
29-
using var streamReader = new StreamReader(stream);
30-
using var jsonTextReader = new JsonTextReader(streamReader);
31-
return GetSerializer().Deserialize<T>(jsonTextReader);
32-
}
33-
}
34-
35-
/// <inheritdoc />
36-
public override Stream ToStream<T>(T input)
37-
{
38-
var streamPayload = new MemoryStream();
39-
using (var streamWriter = new StreamWriter(streamPayload, encoding: DefaultEncoding, bufferSize: 1024, leaveOpen: true))
40-
{
41-
using var jsonTextWriter = new JsonTextWriter(streamWriter);
42-
jsonTextWriter.Formatting = Formatting.None;
43-
GetSerializer().Serialize(jsonTextWriter, input);
44-
jsonTextWriter.Flush();
45-
streamWriter.Flush();
46-
}
47-
48-
streamPayload.Position = 0;
49-
return streamPayload;
50-
}
51-
52-
private static JsonSerializer GetSerializer()
53-
=> MongoDBClientWrapper.Serializer;
54-
}
9+
///// <summary>
10+
///// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
11+
///// the same compatibility standards as public APIs. It may be changed or removed without notice in
12+
///// any release. You should only use it directly in your code with extreme caution and knowing that
13+
///// doing so can result in application failures when updating to a new Entity Framework Core release.
14+
///// </summary>
15+
//public class JsonCosmosDBSerializer : MongoDBRefSerializer
16+
//{
17+
// private static readonly Encoding DefaultEncoding = new UTF8Encoding(false, true);
18+
19+
20+
// /// <inheritdoc />
21+
// public override T FromStream<T>(Stream stream)
22+
// {
23+
// using (stream)
24+
// {
25+
// if (typeof(Stream).IsAssignableFrom(typeof(T)))
26+
// {
27+
// return (T)(object)stream;
28+
// }
29+
30+
// using var streamReader = new StreamReader(stream);
31+
// using var jsonTextReader = new JsonTextReader(streamReader);
32+
// return GetSerializer().Deserialize<T>(jsonTextReader);
33+
// }
34+
// }
35+
36+
// /// <inheritdoc />
37+
// public override Stream ToStream<T>(T input)
38+
// {
39+
// var streamPayload = new MemoryStream();
40+
// using (var streamWriter = new StreamWriter(streamPayload, encoding: DefaultEncoding, bufferSize: 1024, leaveOpen: true))
41+
// {
42+
// using var jsonTextWriter = new JsonTextWriter(streamWriter);
43+
// jsonTextWriter.Formatting = Formatting.None;
44+
// GetSerializer().Serialize(jsonTextWriter, input);
45+
// jsonTextWriter.Flush();
46+
// streamWriter.Flush();
47+
// }
48+
49+
// streamPayload.Position = 0;
50+
// return streamPayload;
51+
// }
52+
53+
// private static JsonSerializer GetSerializer()
54+
// => MongoDBClientWrapper.Serializer;
55+
//}

0 commit comments

Comments
 (0)