Task<int>SaveChangesAsync(CancellationToken cancellationToken =default); Task<bool>SaveEntitiesAsync(CancellationToken cancellationToken =default); } 这两个方法的区别是:一个是返回的 int 是指我们影响的数据条数,另外一个返回 bool 表示我们保存是否成功,本质上这两个方法达到的效果是相同的 另外还定义了一个事务...
_context=context; }publicasyncTask<bool>AddItemAsync(TodoItem newItem) { newItem.Id=Guid.NewGuid(); newItem.IsDone=false; newItem.DueAt= DateTimeOffset.Now.AddDays(3);await_context.AddAsync(newItem);varsaveResult =await_context.SaveChangesAsync();returnsaveResult ==1; }publicTask<TodoItem[]...
public Task<bool> EvaluateAsync(FeatureFilterEvaluationContext context) { var settings = context.Parameters.Get<DebugFeatureSettings>; foreach (var endPointinsettings.DebugEndpoints) { var isDebugEndpoint = _httpContextAccessor.HttpContext.Request.Path.Value.Contains(endPoint); returnTask.FromResult(isDebugE...
public async Task<string> SaveAs(string destinationDir = null){if (this.file == null)throw new ArgumentNullException("没有需要保存的文件");if (destinationDir != null)Directory.CreateDirectory(destinationDir);var newName = DateTime.Now.Ticks;var newFile = Path.Combine(destinationDir ?? "", $"...
public async Task<int> UpdateEntryItemDetail(ProductEntryItemDetailDto valueExpression, Expression<Func<ProductEntryItemDetailDto, bool>> whereExpression) { try { return await Context.Updateable<ProductEntryItemDetailDto>(valueExpression) .IgnoreColumns(ignoreAllNullColumns: true, ignoreAllDefaultValue: ...
public async TaskInvokeAsync(HttpContext httpContext){stringip = httpContext.Connection.RemoteIpAddress.ToString();if(_Banned.Contains(ip)) { httpContext.Response.StatusCode = (int)HttpStatusCode.Forbidden; } CheckIpAddress(ip); await _next(httpContext); ...
publicoverrideasync Task<NotFound> ExecuteAsync(CancellationToken ct){await Task.CompletedTask;returnTypedResults.NotFound;}} 如果你想使用HandleAsync发送TypedResults,你可以使用下面方式: publicclassMyEndpoint:Endpoint<MyRequest, Results<Ok<MyResponse>, NotFound>>{publicoverridevoidConfigure{ ... } ...
public Task<bool> OnSaveAsync(StudentViewModel studentInfo, ItemChangedType changedType) { if(changedType.ToString =="Update") { var queryInfo = StudentInfoList.FirstOrDefault(x => x.StudentID == studentInfo.StudentID); if(queryInfo != null) ...
Why am I using async Task and await for DB calls Why ASP.NET Core 2.2 MVC project require 2 copies of font file (.otf)? !!!HELP!!! Why Can't I Get the Scoped Identity From EF After a Record is Saved? Why can't I use [FromBody] in HttpGet? Why Dapper is only returning the...
public Task<bool> IsActiveAsync(ClaimsPrincipal subject) { return Task.FromResult(true); } } } Client Code: using System; using System.Net; using System.Net.Http; using System.Text; using Thinktecture.IdentityModel.Client; namespace Client ...