小编use*_*907的帖子

属性“ x”不是实体类型“ y”的导航属性

我将EF Core和ASP Core 2.0一起使用。使用最新的身份框架。我在“全部”页面上收到此异常。

InvalidOperationException:属性“ User”不是实体类型“ Gallery”的导航属性。“ include(string)”方法只能与“。”一起使用。导航属性名称的分隔列表。

ApplicationUser看起来像:

public class ApplicationUser : IdentityUser<Guid>
{
    public ICollection<Gallery> Galleries { get; set; }
}
Run Code Online (Sandbox Code Playgroud)

实体图库如下所示:

public class Gallery
{
    public int Id { get; set; }
    public Guid UserId { get; set; }
    public string Title { get; set; }
    public int? ArticleId { get; set; }
    public string Photos { get; set; }
    public DateTime CreatedAt { get; set; }
    public DateTime UpdatedAt { get; set; }

    public Article Article …
Run Code Online (Sandbox Code Playgroud)

c# entity-framework-core asp.net-core

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

C#使用带有DownloadFileAsync的StreamReader从文件读取行

我在使用StreamReaderline != null添加时读取文件时遇到问题textBox1

码:

using(StreamReader reader = new StreamReader("lastupdate.txt"))
{
    string line;

    while((line = reader.ReadLine()) != null)
    {
        textBox1.Text = line;
    }

    reader.Close();
}
Run Code Online (Sandbox Code Playgroud)

它不起作用,我不知道为什么.我尝试使用using StreamReader,我从URL下载文件,我可以在文件夹中看到该文件已下载.该lastupdate.txt是大小1KB.

这是我当前的工作代码MessageBox.如果我删除MessageBox,代码不起作用.它需要某种等待或我不知道:

WebClient client = new WebClient();

client.DownloadFileAsync(new Uri(Settings.Default.patchCheck), "lastupdate.txt"); // ok

if(File.Exists("lastupdate.txt"))
{
    MessageBox.Show("Lastupdate.txt exist");
    using(StreamReader reader = new StreamReader("lastupdate.txt"))
    {
        string line;

        while((line = reader.ReadLine()) != null)
        {
            textBox1.Text = line;
            MessageBox.Show(line.ToString());
        }

        reader.Close();
    }

    File.Delete("lastupdate.txt");
}
Run Code Online (Sandbox Code Playgroud)

c# readline streamreader webclient-download

7
推荐指数
2
解决办法
8万
查看次数

Swift UIButton - 如何删除下划线?

在iOS设置中启用此设置"按钮形状"时出现问题 在此输入图像描述

它在应用程序中引起此下划线(第一张图片启用了设置,第二张没有) 在此输入图像描述

任何想法如何以编程方式或在故事板中禁用它?

我尝试了归因文本,但我得到了相同的结果:(

我是斯威夫特的新手.

感谢帮助!

underline uibutton ios swift

7
推荐指数
1
解决办法
3485
查看次数

htaccess 子文件夹重写规则(不错的网址)

我试图弄清楚如何在子文件夹“admin”中工作,就像在根目录中工作一样,问题是我不知道该怎么做。

目前我有:

RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ ?arg=$1 [L,QSA]

# /
RewriteCond %{REQUEST_URI} !\.[[:alnum:]]+$
RewriteRule ^(.+[^/])$ /$1/ [R=301]
Run Code Online (Sandbox Code Playgroud)

现在它的工作原理如下: http://example.com/page转换为http://example.com/?arg=page

我还想做的是: http://example.com/admin/page翻译成http://example.com/admin/?arg=page

我根本不知道如何实现这一点,有人可以帮助我吗?

谢谢

php apache .htaccess mod-rewrite

5
推荐指数
1
解决办法
8451
查看次数

Blazor - 如何使用 brotli 压缩

Blazor WASM 支持 gzip/brotli 压缩。官方文档显示了示例web.config ,但是此 web.config 未使用托管模型。

如果我将示例 web.config 与根 web.config 合并

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <location path="." inheritInChildApplications="false">
    <system.webServer>
      <handlers>
        <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
      </handlers>
      <aspNetCore processPath="dotnet" arguments=".\app.Server.dll" stdoutLogEnabled="true" stdoutLogFile=".\logs\stdout" hostingModel="inprocess" />
    </system.webServer>
  </location>
</configuration>
Run Code Online (Sandbox Code Playgroud)

Javascript 文件、CSS、图像变得无法访问。我还尝试将示例 web.config 放入 wwwroot/_framework 文件夹中,但根本没有改变。

compression web-config brotli blazor

5
推荐指数
0
解决办法
1589
查看次数

MVC 6 WebAPI FromServices属性将无法编译

我正在关注本教程:http://www.mithunvp.com/create-aspnet-mvc-6-web-api-visual-studio-2015/

哪个应该是最新的,应该适用于rc2

信息:OS:Win 10 x64 14257 VS:15 Update 1 DNX:1.0.0-rc2-16357 clr x86

错误:

CS0592  Attribute 'FromServices' is not valid on this declaration type. It is only valid on 'parameter' declarations.
Run Code Online (Sandbox Code Playgroud)

WebAPIController

[Route("api")]
public class WebAPIController : Controller
{
    [FromServices]
    IWebAPIRepository WebAPI { get; set; }

    [HttpPost("Authenticate", Name = "Authenticate")] // /api/Authenticate
    public async Task<IActionResult> Authenticate([FromBody] LoginViewModel model)
    {
        if (model == null)
            return Ok(new { success = false });

        AuthenticationStatus result = await WebAPI.Authenticate(HttpContext.Authentication, model.Email, model.Password, model.RememberMe); …
Run Code Online (Sandbox Code Playgroud)

c# asp.net asp.net-web-api asp.net-core-mvc

3
推荐指数
1
解决办法
1679
查看次数

C#容器:行,索引

我需要像这样创建容器:Container.Add(RowIndex,ValueIndex);

我知道词典只有关键和价值,这对我不利.我不知道如何使用2个容器创建Row,索引我想要的方式.

例如:

Container[Row][Index]:
Container[0][0] = "Apple";
Container[0][1] = "Orange";
Container[1][0] = "Number";
Run Code Online (Sandbox Code Playgroud)

因为我试图使用这个容器来读取sql.当我得到下一个结果时,它会添加到当前行值+1.和索引均值字段值.

在代码中:

                int row = 0;

                while (ObjReader.Read())
                {
                    foreach (var result in ObjReader)
                        ReadList.Add(row, result.ToString());

                    row++;
                }

                ObjReader.NextResult();
Run Code Online (Sandbox Code Playgroud)

这是为了阅读

现在得到另一个班级的结果

    public string Field(int row, int index)
    {
        return ReadList[row][index];
    }
Run Code Online (Sandbox Code Playgroud)

c# indexing containers row

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

C#unsigned int 96位

你能帮我实现一个代表96位无符号整数的类吗?

我称这个类为Flag96.

码:

class Flag96
{
    private object array = new uint[3];

    public Flag96(uint a1, uint a2, uint a3)
    {
        uint[] _array = (uint[])array;

        _array[0] = a1;
        _array[2] = a2;
        _array[3] = a3;
    }
}
Run Code Online (Sandbox Code Playgroud)

但是当我尝试使用它时:

public Flag96[] example;
Run Code Online (Sandbox Code Playgroud)

不起作用.Microsoft定义的最大整数大小为64位,因此我需要一个新类.

c# int unsigned class

-1
推荐指数
1
解决办法
1167
查看次数