Skip to content

Commit

Permalink
Merge branch 'develop' into release/2.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
azabluda committed Aug 25, 2017
2 parents 4fc5f71 + 56c0548 commit 31cc324
Show file tree
Hide file tree
Showing 66 changed files with 418 additions and 546 deletions.
28 changes: 15 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ It is important to note that InfoCarrier.Core dictates neither the communication
### Credits:
InfoCarrier.Core is bringing together the following open source projects
* [Entity Framework Core](https://github.com/aspnet/EntityFramework) by Microsoft.
* [Remote.Linq](https://github.com/6bee/Remote.Linq) and [aqua-core](https://github.com/6bee/aqua-core) by Christof Senn. You will notice that we are directly using classes `Remote.Linq.Expressions.Expression` and `Aqua.Dynamic.DynamicObject` from these two libraries.
* [Remote.Linq](https://github.com/6bee/Remote.Linq) and [aqua-core](https://github.com/6bee/aqua-core) by Christof Senn.

## Sample

Expand Down Expand Up @@ -60,23 +60,25 @@ public class BloggingContext : DbContext

Implement `IInfoCarrierBackend` interface, e.g. using Windows Communication Foundation
```C#
using IC = InfoCarrier.Core.Common;

public class WcfBackendImpl : IInfoCarrierBackend
{
private readonly ChannelFactory<IMyRemoteService> channelFactory
= new ChannelFactory<IMyRemoteService>(...);

public IEnumerable<Aqua.Dynamic.DynamicObject> QueryData(Remote.Linq.Expressions.Expression rlinq)
public IC.QueryDataResult QueryData(IC.QueryDataRequest request)
{
IMyRemoteService channel = this.channelFactory.CreateChannel()
using ((IDisposable)channel)
{
return channel.ProcessQueryDataRequest(rlinq);
return channel.ProcessQueryDataRequest(request);
}
}

public InfoCarrier.Core.Common.SaveChangesResult SaveChanges(IReadOnlyList<IUpdateEntry> entries)
public IC.SaveChangesResult SaveChanges(IReadOnlyList<IUpdateEntry> entries)
{
var request = new InfoCarrier.Core.Common.SaveChangesRequest(entries);
var request = new IC.SaveChangesRequest(entries);

IMyRemoteService channel = this.channelFactory.CreateChannel()
using ((IDisposable)channel)
Expand Down Expand Up @@ -104,7 +106,7 @@ using (var context = new BloggingContext(optionsBuilder.Options))
where owner.login == "hi-its-me"
where post.Title == "my-blog-post"
select post).Single();

myBlogPost.Date = DateTime.Now;

context.SaveChanges();
Expand All @@ -119,9 +121,9 @@ Use `QueryDataHelper` and `SaveChangesHelper` classes to implement the backend s
[ServiceContract]
public interface IMyRemoteService
{
IEnumerable<DynamicObject> ProcessQueryDataRequest(Remote.Linq.Expressions.Expression rlinq);
SaveChangesResult ProcessSaveChangesRequest(SaveChangesResult request);
QueryDataResult ProcessQueryDataRequest(QueryDataRequest request);

SaveChangesResult ProcessSaveChangesRequest(SaveChangesRequest request);
}

[ServiceBehavior(InstanceContextMode = InstanceContextMode.Single, ConcurrencyMode = ConcurrencyMode.Multiple)]
Expand All @@ -134,15 +136,15 @@ public class MyRemoteService : IMyRemoteService
return new BloggingContext(optionsBuilder.Options);
}

public IEnumerable<DynamicObject> ProcessQueryDataRequest(Remote.Linq.Expressions.Expression rlinq)
public QueryDataResult ProcessQueryDataRequest(QueryDataRequest request)
{
using (var helper = new QueryDataHelper(this.CreateDbContext, rlinq))
using (var helper = new QueryDataHelper(this.CreateDbContext, request))
{
return helper.QueryData();
}
}
public SaveChangesResult ProcessSaveChangesRequest(SaveChangesResult request)

public SaveChangesResult ProcessSaveChangesRequest(SaveChangesRequest request)
{
using (var helper = new SaveChangesHelper(this.CreateDbContext, request))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ namespace InfoCarrier.Core.Client
using Query.ExpressionVisitors.Internal;
using Query.Internal;
using Storage.Internal;
using ValueGeneration.Internal;

public static class InfoCarrierServiceCollectionExtensions
{
Expand All @@ -21,7 +20,7 @@ public static IServiceCollection AddEntityFrameworkInfoCarrierBackend(this IServ
var builder = new EntityFrameworkServicesBuilder(serviceCollection)
.TryAdd<IQueryCompiler, InfoCarrierQueryCompiler>()
.TryAdd<IDatabaseProvider, DatabaseProvider<InfoCarrierOptionsExtension>>()
.TryAdd<IValueGeneratorSelector, InfoCarrierValueGeneratorSelector>()
.TryAdd<IValueGeneratorSelector, RelationalValueGeneratorSelector>()
.TryAdd<IDatabase>(p => p.GetService<IInfoCarrierDatabase>())
.TryAdd<IDbContextTransactionManager, InfoCarrierTransactionManager>()
.TryAdd<IDatabaseCreator, InfoCarrierDatabaseCreator>()
Expand Down
9 changes: 4 additions & 5 deletions src/InfoCarrier.Core/Client/IInfoCarrierBackend.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,16 @@
{
using System.Collections.Generic;
using System.Threading.Tasks;
using Aqua.Dynamic;
using Common;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Update;
using Remote.Linq.Expressions;

public interface IInfoCarrierBackend
{
IEnumerable<DynamicObject> QueryData(Expression rlinq, QueryTrackingBehavior trackingBehavior);
string LogFragment { get; }

Task<IEnumerable<DynamicObject>> QueryDataAsync(Expression rlinq, QueryTrackingBehavior trackingBehavior);
QueryDataResult QueryData(QueryDataRequest request);

Task<QueryDataResult> QueryDataAsync(QueryDataRequest request);

SaveChangesResult SaveChanges(IReadOnlyList<IUpdateEntry> entries);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ public InfoCarrierOptionsExtension(InfoCarrierOptionsExtension copyFrom)

public IInfoCarrierBackend InfoCarrierBackend { get; set; }

public string LogFragment => this.InfoCarrierBackend.LogFragment;

public virtual bool ApplyServices(IServiceCollection services)
{
services.AddEntityFrameworkInfoCarrierBackend();
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
namespace InfoCarrier.Core.Client.Query.ExpressionVisitors.Internal
{
using System;
using System.Linq.Expressions;
using Microsoft.EntityFrameworkCore.Query;
using Microsoft.EntityFrameworkCore.Query.ExpressionVisitors;
Expand All @@ -9,8 +10,6 @@ public class InfoCarrierEntityQueryableExpressionVisitorFactory : IEntityQueryab
{
public virtual ExpressionVisitor Create(
EntityQueryModelVisitor queryModelVisitor, IQuerySource querySource)
=> new InfoCarrierEntityQueryableExpressionVisitor(
queryModelVisitor,
querySource);
=> throw new InvalidOperationException(@"InfoCarrier.Core is not using EntityQueryModelVisitor");
}
}
Loading

0 comments on commit 31cc324

Please sign in to comment.