I am using a LINQ query on a DbSet<T>
:
await _dbContext.Users.AnyAsync(u => u.Name == name);
Run Code Online (Sandbox Code Playgroud)
However, the compiler outputs the following error:
Error CS0121: The call is ambiguous between the following methods or properties:
'System.Linq.AsyncEnumerable.AnyAsync<TSource>(System.Collections.Generic.IAsyncEnumerable<TSource>, System.Func<TSource, bool>)' and
'Microsoft.EntityFrameworkCore.EntityFrameworkQueryableExtensions.AnyAsync<TSource>(System.Linq.IQueryable<TSource>, System.Linq.Expressions.Expression<System.Func<TSource, bool>>)'
Run Code Online (Sandbox Code Playgroud)
A similar problem also occurs with other LINQ extension methods, like .Where()
.
I am using EF.Core 3.1 and have the System.Linq.Async
package installed. How do I fix this issue?
c# linq ambiguous entity-framework-core entity-framework-core-3.1
我将以下代码导入到我的 .tsx 组件中:
import resolveConfig from 'tailwindcss/resolveConfig';
import tailwindConfig from '../../../tailwind.config.js';
const fullConfig = resolveConfig(tailwindConfig)
Run Code Online (Sandbox Code Playgroud)
如果我随后引用,fullConfig.theme.colors["blue"]["700"]
则会收到一条错误消息:
元素隐式具有“any”类型,因为“blue”类型的表达式不能用于索引类型“TailwindThemeColors”。类型“TailwindThemeColors”上不存在属性“蓝色”。
颜色的 Tailwind 类型定义是:
export type TailwindColorValue = string | TailwindColorGroup | TailwindColorFunction;
export interface TailwindValuesColor {
readonly [key: string]: TailwindColorValue;
}
Run Code Online (Sandbox Code Playgroud)
由于该类型没有明确指出这"blue"
是一个值并且它可能是一个对象,所以这就是错误的原因(我认为)。
我遇到的另一个问题是我的 中出现错误tsconfig.json
,因为我正在导入 JS 文件。添加并"exclude": ["tailwind.config.js"]
不能解决问题。
我很确定这是一个 Typescript 问题,而不是 Tailwind 问题......
我的问题是:
"blue"
顺风主题中颜色的属性,以及我正在学习 DOM,我无法理解:firstChild
和之间有什么区别firstElementChild
?
我想更新我的软件包,但我遇到了一些这样的错误:
错误是:
错误 NU1202 Package Microsoft.EntityFrameworkCore.Sqlite 5.0.0-rc.1.20451.13 与 net50 (.NETFramework,Version=v5.0) / win7-x86 不兼容。包 Microsoft.EntityFrameworkCore.Sqlite 5.0.0-rc.1.20451.13 支持:netstandard2.1 (.NETStandard,Version=v2.1) API E:...\API\API.csproj 1
API.csproj 文件:
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="8.0.1" />
<PackageReference Include="CloudinaryDotNet" Version="1.11.0" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="3.1.7" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="5.0.0-preview.8.20414.8" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="5.0.0-preview.8.20407.4">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="5.0.0-preview.8.20407.4" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="5.0.0-preview8" />
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="6.7.1" />
</ItemGroup>
</Project>
Run Code Online (Sandbox Code Playgroud)
C:\WINDOWS\system32>dotnet --info .NET SDK(反映任何 global.json):
版本:5.0.100-rc.1.20452.10
提交:473d1b592e运行时环境:
操作系统名称:Windows
操作系统版本:10.0.17763 操作系统平台:Windows …
我在尝试显示数据库中的数据时出错。这个问题是由在本网站上创建帖子的其他人发生的。但他们有一个 foreach 循环而我没有。所以针对这个问题给出的所有答案都不起作用。
物品控制器
public function showwereld($id)
{
$artikels = Artikel::where('id', $id);
return view('pages.show')->with('artikels', $artikels);
}
Run Code Online (Sandbox Code Playgroud)
show.blade.php
public function showwereld($id)
{
$artikels = Artikel::where('id', $id);
return view('pages.show')->with('artikels', $artikels);
}
Run Code Online (Sandbox Code Playgroud)
我正在使用 Mailkit 库发送电子邮件。这是这样做的代码:
public async Task SendAsync(IdentityMessage message)
{
if (message == null)
return;
LinkedResource inline = new LinkedResource(System.Web.Hosting.HostingEnvironment.MapPath($"~/Images/logo.png"))
{
ContentId = Guid.NewGuid().ToString(),
ContentType = new ContentType("image/png")
{
Name = "logo.png"
}
};
var htmlBody = message.Body.Replace("{CID:LOGO}", String.Format("cid:{0}", inline.ContentId));
AlternateView avHtml = AlternateView.CreateAlternateViewFromString(htmlBody, null, MediaTypeNames.Text.Html);
avHtml.LinkedResources.Add(inline);
using (MailMessage objMailMsg = new MailMessage())
{
objMailMsg.AlternateViews.Add(avHtml);
objMailMsg.Body = htmlBody;
objMailMsg.Subject = message.Subject;
objMailMsg.BodyEncoding = Encoding.UTF8;
Properties.Settings.Default.Reload();
string fromEmail = Properties.Settings.Default.FromMail;
string fromName = Properties.Settings.Default.FromName;
string smtpPassword = Properties.Settings.Default.PwdSmtp;
objMailMsg.From = new MailAddress(fromEmail, …
Run Code Online (Sandbox Code Playgroud) 我需要从 C# 控制台应用程序启动一个进程,然后允许控制台应用程序完成/结束,而无需等待进程/线程完成。
我该怎么做呢?
只需浏览本教程:https : //www.davepaquette.com/archive/2019/02/06/managing-transactions-in-dapper.aspx
我的理解(没有 Dapper)是一旦你有一个连接,你可以打开一个事务,然后执行一堆语句,然后提交或回滚事务。这些查询不需要引用事务,因为连接已经“知道”了它。
那么为什么每次执行某些操作时,Dapper 都需要事务?
当我进入工具| NuGet 包管理器| 管理解决方案的 NuGet 包,它显示我有 12 个可用更新。
但是当我尝试全部更新它们时,出现错误。
NU1202: Package Microsoft.VisualStudio.Web.CodeGeneration 5.0.0 is not compatible with netcoreapp3.1 (.NETCoreApp,Version=v3.1). Package Microsoft.VisualStudio.Web.CodeGeneration 5.0.0 supports: net5.0 (.NETCoreApp,Version=v5.0)
NU1202: Package Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore 5.0.0 is not compatible with netcoreapp3.1 (.NETCoreApp,Version=v3.1). Package Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore 5.0.0 supports: net5.0 (.NETCoreApp,Version=v5.0)
NU1202: Package Microsoft.VisualStudio.Web.CodeGeneration.Utils 5.0.0 is not compatible with netcoreapp3.1 (.NETCoreApp,Version=v3.1). Package Microsoft.VisualStudio.Web.CodeGeneration.Utils 5.0.0 supports: net5.0 (.NETCoreApp,Version=v5.0)
NU1202: Package Microsoft.VisualStudio.Web.CodeGeneration.Contracts 5.0.0 is not compatible with netcoreapp3.1 (.NETCoreApp,Version=v3.1). Package Microsoft.VisualStudio.Web.CodeGeneration.Contracts 5.0.0 supports: net5.0 (.NETCoreApp,Version=v5.0)
NU1202: Package Microsoft.VisualStudio.Web.CodeGenerators.Mvc …
Run Code Online (Sandbox Code Playgroud) visual-studio nuget asp.net-core asp.net-core-3.1 asp.net-core-5.0
我有以下 Markdown 字符串:
`log-level` (optional)<br>
Sets the minimal log level messages need in order to be printed to stdout.
Allowed values:
- `debug`
- `warning`
- `error` (default)
Run Code Online (Sandbox Code Playgroud)
GitHub 和 Stack Overflow 是这样渲染的(添加了块引用以进行视觉区分):
log-level
(可选)
设置打印到标准输出所需的最低日志级别消息。允许值:
debug
warning
error
(默认)
如此处和屏幕截图所示,Markdown 渲染器在最后一段(“允许的值”)和第一个列表项之间添加了间距。
检查生成的 HTML 可以看出原因:
`log-level` (optional)<br>
Sets the minimal log level messages need in order to be printed to stdout.
Allowed values:
- `debug`
- `warning`
- `error` (default)
Run Code Online (Sandbox Code Playgroud)
文本“允许的值”放置在自己的标记中,并且和后面的<p>
之间有空白。<p>
<ul>
有没有办法减少或消除该空间,使其大致匹配列表项之间的空间?
c# ×4
nuget ×2
.net-5 ×1
ambiguous ×1
asp.net-core ×1
dapper ×1
laravel ×1
linq ×1
mailkit ×1
markdown ×1
php ×1
process ×1
reactjs ×1
smtpclient ×1
tailwind-css ×1
tsx ×1
typescript ×1
web ×1