小编Pri*_*ico的帖子

EF Core:当前上下文中不存在名称"SqlServerValueGenerationStrategy"

我刚刚将我的项目更新为ASP .NET Core 2.1,当我运行时:

migrations add InitialCreate
Run Code Online (Sandbox Code Playgroud)

它创建了一个迁移文件夹,但是我收到此错误,我的项目将无法构建:

当前上下文中不存在名称"SqlServerValueGenerationStrategy".

entity-framework-core asp.net-core

27
推荐指数
2
解决办法
9910
查看次数

Elasticsearch 6:拒绝映射更新,因为最终映射将具有多于1种类型

我正在尝试将项目转换为使用最新的Elasticsearch 6并遇到此问题.我不知道问题是"产品"还是"产品".在我的映射和属性中,我指定了"产品",所以当我尝试索引产品时,我不确定为什么会出现此错误.

错误:

从PUT上的不成功低级别调用构建的无效NEST响应:/ products/products/1?pretty = true&error_trace = true

"拒绝将映射更新到[products],因为最终的映射将有多种类型:[Product,products]"

请求:

{
  "id": 1,
  "warehouseId": 0,
  "productStatus": 1,
  "sku": "102377",
  "name": "Name",
  "shortDescription": "Description",
  "longDescription": "Description",
  "price": 37.3200
}
Run Code Online (Sandbox Code Playgroud)

我的代码:

    [ElasticsearchType(Name = "products")]
    public class Product : BaseEntity
    {
        [Key]
        public int Id { get; set; }
        public int WarehouseId { get; set; }
        [Display(Name = "Product Status")]
        public Enums.ProductStatus ProductStatus { get; set; }
        [Required, StringLength(10)]
        public string Sku { get; set; }
        [Required, StringLength(200)]
        public string Name { …
Run Code Online (Sandbox Code Playgroud)

elasticsearch

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

Swift 3.0中的完成处理程序

我使用下面的代码与我的服务器同步数据.完成任务后,我想打电话给:

self.refreshControl?.endRefreshing()
Run Code Online (Sandbox Code Playgroud)

但是,我想确保它发生在此方法中可能发生的任何事情之后.这是我要使用完成处理程序的地方吗?这让我感到困惑,因为我已经运行了在获得http响应后执行的代码.如果我添加一个完成处理程序,它会在收到http响应后执行吗?我可以将我的endRefreshing()代码放在那里,这可能发生在下面的代码中可能发生的任何事情之后吗?谢谢!

func syncCustomers(token: String) {
    let url:NSURL = NSURL(string: Constants.Api.BaseUrl + "api/customer")!
    let session = URLSession.shared
    let request = NSMutableURLRequest(url: url as URL)
    request.setValue("Bearer \(token)", forHTTPHeaderField: "Authorization")
    request.httpMethod = "GET"
    let task = session.dataTask(with: request as URLRequest) { (data, response, error) in
        guard let data = data else { return }
        do {
            if error != nil {
                self.showAlert(title: "Error", message: error!.localizedDescription)
            }
            else if let httpResponse = response as? HTTPURLResponse {
                if httpResponse.statusCode == 200 {
                    let …
Run Code Online (Sandbox Code Playgroud)

swift3

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

带有Web API的Azure B2C

我看到使用Azure B2C和Web API的示例显示app.UseOAuthBearerAuthentication(如下所示),但我的ASP .NET 5 Web API项目使用IApplicationBuilder(不是IAppBuilder),并且UseOAuthBearerAuthentication不存在.我已经尝试了app.UseOpenIdConnectAuthentication,但是我相信这会使用cookie,而我无法使用Xamarin应用程序作为客户端.我已经尝试了app.UseWindowsAzureActiveDirectoryBearerAuthentication但我相信这是针对标准的Azure AD(不是B2C)是真的吗?有关如何使Azure B2C使用最新的ASP .NET Web API的任何想法?

谢谢!!!

    public void ConfigureAuth(IAppBuilder app)
    {   
        TokenValidationParameters tvps = new TokenValidationParameters
        {
            // This is where you specify that your API only accepts tokens from its own clients
            ValidAudience = clientId,
        };

        app.UseOAuthBearerAuthentication(new OAuthBearerAuthenticationOptions
        {   
            // This SecurityTokenProvider fetches the Azure AD B2C metadata & signing keys from the OpenIDConnect metadata endpoint
            AccessTokenFormat = new JwtFormat(tvps, new OpenIdConnectCachingSecurityTokenProvider(String.Format(aadInstance, tenant, "v2.0", discoverySuffix, commonPolicy)))
        });
    }
Run Code Online (Sandbox Code Playgroud)

azure asp.net-web-api2 azure-ad-b2c

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

Azure Notification Hubs软件包是否与.NET Core兼容?

我正在使用.NET核心应用程序,我看到一些Azure软件包不兼容,例如NotificationHubsSendGrid:

Package Microsoft.Azure.NotificationHubs 1.0.5 is not compatible with netcoreapp1.0 (.NETCoreApp,Version=v1.0)
The dependency SendGrid.CSharp.HTTP.Client 2.0.4 does not support framework .NETCoreApp, Version=v1.0
Run Code Online (Sandbox Code Playgroud)

我只尝试添加NotificationHubs和SendGrid.我还没有尝试过任何ActiveDirectory包.

有没有人知道其中一些软件包是否会很快兼容?或者也许我做错了什么?或者.NET核心应用程序中是否有一种方法可以引用较旧的包?

谢谢!

c# azure azure-notificationhub .net-core uwp

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

ASP .NET Core Razor:模型绑定复杂类型不得是抽象或值类型,并且必须具有无参数构造函数

如果我的模型中有这样的属性:

    [BindProperty]
    public IPagedList<Product> Products { get; set; }
Run Code Online (Sandbox Code Playgroud)

然后当我尝试发帖时,我收到此错误:

An unhandled exception occurred while processing the request.
InvalidOperationException: Could not create an instance of type 'X.PagedList.IPagedList`1[Data.Models.Product, Data, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]'. Model bound complex types must not be abstract or value types and must have a parameterless constructor. Alternatively, set the 'Products' property to a non-null value in the 'Areas.Catalog.Pages.ProductListModel' constructor.
Run Code Online (Sandbox Code Playgroud)

该错误表明我可以在构造函数中将该属性设置为非空值,因此我尝试在构造函数中执行此操作:

Products = new PagedList<Product>(Enumerable.Empty<Product>(), 1, 10);
Run Code Online (Sandbox Code Playgroud)

但我得到了同样的错误。

ajax razor asp.net-core

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

在Swift中按键获取字典中的项目索引

我这样做是为了遍历我的字典,直到我匹配密钥.我的字典被定义为[Int:String]

var index = 0
for (key, value) in mylist! {
    if key == property.propertyValue as! Int {
        // use index here
    }
    index += 1
}
Run Code Online (Sandbox Code Playgroud)

有一个更好的方法吗?我看到了过滤的例子(类似下面的例子),但我不知道如何使它与字典一起工作.我可以使用这样的东西来找到项目的索引吗?或者还有另一种方式吗?

mylist.filter{$0.key == 1}
Run Code Online (Sandbox Code Playgroud)

更新: 这有效:

let index = Array(mylist!.keys).index(of: 1)
Run Code Online (Sandbox Code Playgroud)

但这不是:

let index = mylist!.index(forKey: 1)
Run Code Online (Sandbox Code Playgroud)

看来他们俩都应该工作.我想知道为什么第二个没有.

swift

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

为什么 Bootstrap 4 弹出窗口中缺少 HTML 属性?

$(document).ready(function () {
        $("[data-toggle=popover]").popover({
            html: true,
            content: function () {
                return "<div style='color:red;'>test</div>";
            }
        });
});
Run Code Online (Sandbox Code Playgroud)
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>

<a class="btn btn-primary" data-html="true" data-toggle="popover" data-placement="bottom">Click Me</a>
Run Code Online (Sandbox Code Playgroud)

当我在 Bootstrap 4 弹出窗口中使用 HTML 内容时,缺少 HTML 属性。我希望看到红色文本,但它输出没有红色样式的 div 标签。

    $("[data-toggle=popover]").popover({
        html: true,
        content: function () {
            return "<div style='color: red;'>Test</div>";
        }
    });
Run Code Online (Sandbox Code Playgroud)

jquery twitter-bootstrap

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

登录 AWS Workmail 时出现访问错误

我的 AWS 工作邮件域是这样的:

mydomain-com.awsapps.com

我创建了一个用户,但是当我尝试从浏览器登录时,出现以下错误。不过我可以在 iPhone 上收到电子邮件。

访问错误 该应用程序尚未为您的目录启用。请联系您的管理员了解更多详情。

amazon-web-services amazon-workmail

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