diff --git a/src/Cap.Consistency.EntityFrameworkCore/ConsistencyEntityFrameworkBuilderExtensions.cs b/src/Cap.Consistency.EntityFrameworkCore/ConsistencyEntityFrameworkBuilderExtensions.cs index abca1cc..1d5eb99 100644 --- a/src/Cap.Consistency.EntityFrameworkCore/ConsistencyEntityFrameworkBuilderExtensions.cs +++ b/src/Cap.Consistency.EntityFrameworkCore/ConsistencyEntityFrameworkBuilderExtensions.cs @@ -1,5 +1,5 @@ -using Cap.Consistency.EntityFrameworkCore; -using Cap.Consistency.Store; +using Cap.Consistency; +using Cap.Consistency.EntityFrameworkCore; using Microsoft.EntityFrameworkCore; namespace Microsoft.Extensions.DependencyInjection diff --git a/src/Cap.Consistency.EntityFrameworkCore/ConsistencyMessageStore.cs b/src/Cap.Consistency.EntityFrameworkCore/ConsistencyMessageStore.cs index ee0a645..6f75520 100644 --- a/src/Cap.Consistency.EntityFrameworkCore/ConsistencyMessageStore.cs +++ b/src/Cap.Consistency.EntityFrameworkCore/ConsistencyMessageStore.cs @@ -1,8 +1,8 @@ using System; +using System.Linq; using System.Threading; using System.Threading.Tasks; using Cap.Consistency.Infrastructure; -using Cap.Consistency.Store; using Microsoft.EntityFrameworkCore; namespace Cap.Consistency.EntityFrameworkCore @@ -126,6 +126,24 @@ namespace Cap.Consistency.EntityFrameworkCore return OperateResult.Success; } + public Task GetFirstEnqueuedMessageAsync(CancellationToken cancellationToken) { + cancellationToken.ThrowIfCancellationRequested(); + return MessageSet.AsNoTracking().Where(x => x.Status == MessageStatus.WaitForSend).FirstOrDefaultAsync(cancellationToken); + } + + //public void ChangeState(ConsistencyMessage message, MessageStatus status) { + // Context.Attach(message); + // message.Status = status; + // Context.Update(message); + // try { + // await SaveChanges(cancellationToken); + // } + // catch (DbUpdateConcurrencyException ex) { + // return OperateResult.Failed(new OperateError() { Code = "DbUpdateConcurrencyException", Description = ex.Message }); + // } + // return OperateResult.Success; + //} + /// /// Gets or sets a flag indicating if changes should be persisted after CreateAsync, UpdateAsync and DeleteAsync are called. ///