我有以下代码,我正在尝试使用ef core更新ClientAccount,但是它们并发检查失败:
public class ClientAccount
{
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public long Id { get; set; }
[Required]
[ConcurrencyCheck]
public double Balance { get; set; }
[Required]
public DateTime DateTimeCreated { get; set; }
[Required]
public DateTime DateTimeUpdated { get; set; }
}
public class ClientRepository
{
private readonly MyContext context;
public ClientRepository(MyContext context)
{
this.context = context;
}
public ClientAccount GetClientAccount()
{
return (from client in context.ClientAccount
select client).SingleOrDefault();
}
public void Update(ClientAccount client)
{
context.Update(client);
context.Entry(client).Property(x => x.DateTimeCreated).IsModified = false; …Run Code Online (Sandbox Code Playgroud) 我已将标题单元格和单元格的样式设置为右对齐,但标题仅与单元格文本对齐
这是一个示例的链接
我已经添加了
.mat-cell, .mat-header-cell {
text-align: right;
}
Run Code Online (Sandbox Code Playgroud) 我在 Asp.Net Core 3.1 中有以下代码
public void ConfigureServices(IServiceCollection services)
{
services.AddAuthentication(options =>
{
options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
options.DefaultScheme = JwtBearerDefaults.AuthenticationScheme;
options.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme;
}).AddJwtBearer();
}
public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory)
{
app.UseRouting();
app.UseCors(DefaultCorsPolicyName);
app.UseAuthentication();
app.UseAuthorization();
app.UseEndpoints(endpoints =>
{
endpoints.MapControllerRoute("default", "{controller}/{action}/{id?}").RequireAuthorization(new AuthorizeAttribute());
});
}
[ApiController]
[Route("[controller]/[action]")]
public class TestController : ControllerBase
{
[HttpGet]
public string Test()
{
return "Test works!";
}
}
Run Code Online (Sandbox Code Playgroud)
但所有请求都通过并且没有授权工作。知道为什么会这样吗?
我有以下通过 Visual Studio 2019 创建的 pubxml 文件:
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<WebPublishMethod>FileSystem</WebPublishMethod>
<PublishProvider>FileSystem</PublishProvider>
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
<LastUsedPlatform>Any CPU</LastUsedPlatform>
<SiteUrlToLaunchAfterPublish />
<LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
<ExcludeApp_Data>False</ExcludeApp_Data>
<TargetFramework>netcoreapp3.1</TargetFramework>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<ProjectGuid>143a6329-27d9-474e-9521-835be634c293</ProjectGuid>
<SelfContained>true</SelfContained>
<publishUrl>bin\Release\netcoreapp3.1\publish\</publishUrl>
<DeleteExistingFiles>True</DeleteExistingFiles>
</PropertyGroup>
</Project>
Run Code Online (Sandbox Code Playgroud)
当我运行dotnet.exe publish src\MyProject.Web.sln -p:PublishProfile=Properties\PublishProfiles\ProductionPublish.pubxmlRelease 不包含任何内容并且发布发生在 Debug 文件夹(调试版本)上。为什么会发生这种情况并且忽略 pubxml?
更新 #1
Structure
src\MyProject\MyProject.csproj
src\MyProject.Utils\ect.Utils.csproj
src\MyProject.Web\MyProject.Web.csproj
src\MyProject.Web.sln
Run Code Online (Sandbox Code Playgroud)
和 pubxml 的路径
src\MyProject.Web\Properties\PublishProfiles\ProductionPublish.pubxml
Run Code Online (Sandbox Code Playgroud) 我有一个项目需要查询数据库并将结果返回到 web api。有几个存储过程是由 DB Admin 即时创建的,它们有一个 UI,用于创建存储过程的定义和它的名称,Web api 服务只调用该 SP 并应该返回结果。根据下面的代码,我无法将返回对象返回到 web api 控制器,因为对象包含项目但没有映射属性。
var result = dbContext.Query<object>().AsNoTracking().FromSql(
"dbo.MY_SP @DateFrom=@DateFrom, @DateTo=@DateTo",
dateFromParam, dateToParam).ToList();
Run Code Online (Sandbox Code Playgroud) 当我尝试调用我的项目上的控制器时,我收到以下错误,该控制器使用 oWin 和 Quartz.Net 3.0.7 和 Autofac 。
{
"Message": "An error has occurred.",
"ExceptionMessage": "An error occurred when trying to create a controller of type 'QuartzController'. Make sure that the controller has a parameterless public constructor.",
"ExceptionType": "System.InvalidOperationException",
"StackTrace": " at System.Web.Http.Dispatcher.DefaultHttpControllerActivator.Create(HttpRequestMessage request, HttpControllerDescriptor controllerDescriptor, Type controllerType)\r\n at System.Web.Http.Dispatcher.HttpControllerDispatcher.<SendAsync>d__15.MoveNext()",
"InnerException": {
"Message": "An error has occurred.",
"ExceptionMessage": "An exception was thrown while activating Chatech.Quartz.Owin.Controllers.QuartzController -> Chatech.Quartz.Owin.Application.JobInformation.JobInformationService -> ?:Quartz.IScheduler.",
"ExceptionType": "Autofac.Core.DependencyResolutionException",
"StackTrace": " at Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable`1 parameters, Object& decoratorTarget) in C:\\projects\\autofac\\src\\Autofac\\Core\\Resolving\\InstanceLookup.cs:line …Run Code Online (Sandbox Code Playgroud) 我有以下代码,当我调用 api 端点时出现错误 Bearer was not authenticated. Failure message: IDX10500: Signature validation failed. No security keys were provided to validate the signature.
services.AddAuthentication(options =>
{
options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
options.DefaultScheme = JwtBearerDefaults.AuthenticationScheme;
options.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme;
})
.AddJwtBearer(cfg =>
{
cfg.RequireHttpsMetadata = false;
cfg.TokenValidationParameters = new TokenValidationParameters
{
ValidateAudience = false,
ValidateIssuer = false,
ValidateIssuerSigningKey = false
};
});
Run Code Online (Sandbox Code Playgroud)
如果我设置了,为什么会发生这种情况ValidateIssuerSigningKey=false?
我正在使用最新的Serilog.File 4.1.0和Serilog.Sinks.Async. 异步日志记录有效,但我希望滚动文件。如何启用文件滚动?
我有以下内容:
Log.Logger = new LoggerConfiguration()
.WriteTo.Async(a =>
{
a.File("logs/logs.log");
})
.MinimumLevel.Verbose()
.CreateLogger();
Run Code Online (Sandbox Code Playgroud) 我为 VS2019 创建了一个自定义模板,其中包含两个项目。下面是我的 root.vstemplate 文件
<VSTemplate Version="3.0.0" Type="ProjectGroup" xmlns="http://schemas.microsoft.com/developer/vstemplate/2005">
<TemplateData>
<Name>Asp.Net Core Template EF Core</Name>
<Description>Asp.Net Core 3.1 Boilerplate template</Description>
<ProjectType>CSharp</ProjectType>
<ProjectSubType>
</ProjectSubType>
<SortOrder>1000</SortOrder>
<CreateNewFolder>true</CreateNewFolder>
<DefaultName>Asp.Net Core Template EF Core</DefaultName>
<ProvideDefaultName>true</ProvideDefaultName>
<LocationField>Enabled</LocationField>
<EnableLocationBrowseButton>true</EnableLocationBrowseButton>
<Icon>logo.png</Icon>
</TemplateData>
<TemplateContent>
<ProjectCollection>
<ProjectTemplateLink ProjectName="AspNet Core Ef Core">
src\AspNetCore3EfCoreTemplate\MyTemplate.vstemplate
</ProjectTemplateLink>
<ProjectTemplateLink ProjectName="AspNet Core Ef Core Web">
src\AspNetCore3EfCoreTemplate.Web\MyTemplate.vstemplate
</ProjectTemplateLink>
</ProjectCollection>
</TemplateContent>
</VSTemplate>
Run Code Online (Sandbox Code Playgroud)
我按照此链接的说明进行操作,但是当我尝试在 VS2019 中创建新项目时未显示我的模板。有谁知道为什么会这样?
visual-studio visual-studio-extensions .net-core visual-studio-2019
我有一个只有一列的 csv,我正在使用 Papa Parse 库来解析 csv。我收到以下错误Unable to auto-detect delimiting character; defaulted to ','
由于它只是一列,因此它不是逗号分隔值。我试图将 delimeter 配置属性设置为 autodelimiter: "",但仍然是同样的问题
当使用 Primeng 表格并将表格设置为可滚动时,表格应显示滚动条,并且单元格内的文本不应溢出。相反,这不会发生。
在Stackblitz 中检查此示例并调整大小
.net ×7
c# ×7
.net-core ×3
angular ×3
asp.net-core ×2
asp.net ×1
css ×1
ef-core-2.0 ×1
javascript ×1
jwt ×1
msbuild ×1
papaparse ×1
primeng ×1
quartz.net ×1
serilog ×1