小编Jan*_*ann的帖子

Ambiguous call when using LINQ extension method on DbSet<T>

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

34
推荐指数
1
解决办法
6952
查看次数

如何通过 Typescript 使用 TailwindCSS 的解析配置

我将以下代码导入到我的 .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 问题......

我的问题是:

  1. 如何让 Typescript 了解"blue"顺风主题中颜色的属性,以及
  2. 如何阻止导入 JS 配置时出现 tsconfig 错误?

typescript reactjs tsx tailwind-css

21
推荐指数
1
解决办法
2万
查看次数

`firstChild` 和 `firstElementChild` 有什么区别?

我正在学习 DOM,我无法理解:firstChild和之间有什么区别firstElementChild

web

17
推荐指数
1
解决办法
3376
查看次数

包 Microsoft.EntityFrameworkCore.Sqlite 5.0.0-rc.1.20451.13 与 net50 (.NETFramework,Version=v5.0) / win7-x86 不兼容

我想更新我的软件包,但我遇到了一些这样的错误:

错误是:

错误 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)

nuget 包管理器

C:\WINDOWS\system32>dotnet --info .NET SDK(反映任何 global.json):
版本:5.0.100-rc.1.20452.10
提交:473d1b592e

运行时环境:
操作系统名称:Windows
操作系统版本:10.0.17763 操作系统平台:Windows …

nuget entity-framework-core .net-5 asp.net-core-5.0

14
推荐指数
2
解决办法
1万
查看次数

Laravel 属性 [title] 在 Eloquent 构建器实例中不存在

我在尝试显示数据库中的数据时出错。这个问题是由在本网站上创建帖子的其他人发生的。但他们有一个 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)

在此处输入图片说明

php laravel laravel-blade

10
推荐指数
2
解决办法
3万
查看次数

更改电子邮件中自动附加文件的名称

我正在使用 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# smtpclient email-attachments mailkit

10
推荐指数
1
解决办法
120
查看次数

启动进程并允许调用者结束而无需等待进程完成

我需要从 C# 控制台应用程序启动一个进程,然后允许控制台应用程序完成/结束,而无需等待进程/线程完成。

我该怎么做呢?

c# process

9
推荐指数
2
解决办法
9501
查看次数

为什么 Dapper 在执行查询时需要对事务的引用?

只需浏览本教程:https : //www.davepaquette.com/archive/2019/02/06/managing-transactions-in-dapper.aspx

我的理解(没有 Dapper)是一旦你有一个连接,你可以打开一个事务,然后执行一堆语句,然后提交或回滚事务。这些查询不需要引用事务,因为连接已经“知道”了它。

那么为什么每次执行某些操作时,Dapper 都需要事务?

c# dapper

9
推荐指数
1
解决办法
247
查看次数

NuGet 包管理器尝试将 .NET 5.0 更新添加到 .NET Core 3.1 应用程序

当我进入工具| 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

9
推荐指数
1
解决办法
2万
查看次数

删除 Markdown 中列表前的空格

我有以下 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(默认)

截图来自GitHub


如此处和屏幕截图所示,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>


有没有办法减少或消除该空间,使其大致匹配列表项之间的空间?

markdown

8
推荐指数
1
解决办法
7621
查看次数