瀏覽代碼

refactor

master
yangxiaodong 7 年之前
父節點
當前提交
73556221b3
共有 2 個文件被更改,包括 21 次插入3 次删除
  1. +2
    -2
      src/Cap.Consistency.EntityFrameworkCore/ConsistencyEntityFrameworkBuilderExtensions.cs
  2. +19
    -1
      src/Cap.Consistency.EntityFrameworkCore/ConsistencyMessageStore.cs

+ 2
- 2
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


+ 19
- 1
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<ConsistencyMessage> 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;
//}

/// <summary>
/// Gets or sets a flag indicating if changes should be persisted after CreateAsync, UpdateAsync and DeleteAsync are called.
/// </summary>


Loading…
取消
儲存