小编Nic*_*icy的帖子

Typecript中排序错误的类型

var cheapest = leaves.sort((a,b) => <boolean>(<number>a.cost < <number>b.cost));
//also tried without casting
Run Code Online (Sandbox Code Playgroud)

给我以下错误:

'Error'
message: 'Argument of type '(a: any, b: any) => boolean' is not assignable to parameter of type '(a: any, b: any) => number'.
Type 'boolean' is not assignable to type 'number'.'
Run Code Online (Sandbox Code Playgroud)

我该如何解决这个问题?

编辑:js代码(原始)取自:https: //github.com/atomicptr/goap/blob/gh-pages/gameplay/ai/planner.js,它确实似乎按bool而不是数字排序.

sorting typescript typescript2.0

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

RoR 3 - f.label嵌入了<span>标签 - howto

我该怎么做?

我目前的代码是:

<%= f.label :email, html_escape("<span class=\"big\">Test</span>")   %>
Run Code Online (Sandbox Code Playgroud)

这并没有显示我想要的东西,因为

<span class=\"big\">Test</span>
Run Code Online (Sandbox Code Playgroud)

显示为文本而不是HTML.

我一直在考虑覆盖FormBuilder,但我不知道如何做到这一点并且搜索类似的东西并没有解决我的问题.

此外,而不是测试我想显示变量:电子邮件.

我只是想解决我有的问题:)

PS.我正在使用Rails 3.0.

forms ruby-on-rails formbuilder ruby-on-rails-3

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

Visual Studio - 程序包管理器控制台 - 以编程方式运行命令

好的,

每次我更新生产网站时,我都需要运行5个命令,这些命令只是名称不同.

我想自动化这个(将来,我可能需要100次运行这些命令).

我做的是:

Update-Database -ConfigurationTypeName "SlaveConfiguration" -StartupProjectName "FacturatieMVCv2.Data" -Verbose -ConnectionString "Server=PC-1\SQLEXPRESS;Persist Security Info=True;Initial Catalog=Database1;uid=prog;password=ndp103@50;" -ConnectionProviderName "System.Data.SqlClient" 
Update-Database -ConfigurationTypeName "SlaveConfiguration" -StartupProjectName "FacturatieMVCv2.Data" -Verbose -ConnectionString "Server=PC-1\SQLEXPRESS;Persist Security Info=True;Initial Catalog=Database2;uid=prog;password=ndp103@50;" -ConnectionProviderName "System.Data.SqlClient" 
Update-Database -ConfigurationTypeName "SlaveConfiguration" -StartupProjectName "FacturatieMVCv2.Data" -Verbose -ConnectionString "Server=PC-1\SQLEXPRESS;Persist Security Info=True;Initial Catalog=Database3;uid=prog;password=ndp103@50;" -ConnectionProviderName "System.Data.SqlClient" 
Update-Database -ConfigurationTypeName "SlaveConfiguration" -StartupProjectName "FacturatieMVCv2.Data" -Verbose -ConnectionString "Server=PC-1\SQLEXPRESS;Persist Security Info=True;Initial Catalog=Database4;uid=prog;password=ndp103@50;" -ConnectionProviderName "System.Data.SqlClient" 
Update-Database -ConfigurationTypeName "SlaveConfiguration" -StartupProjectName "FacturatieMVCv2.Data" -Verbose -ConnectionString "Server=PC-1\SQLEXPRESS;Persist Security Info=True;Initial Catalog=Database5;uid=prog;password=ndp103@50;" -ConnectionProviderName "System.Data.SqlClient" 
Run Code Online (Sandbox Code Playgroud)

我怎么能写i脚本,这样,当我输入控制台管理器时:

Update-Database -type Production -version latest
Run Code Online (Sandbox Code Playgroud)

它运行上面的所有命令,没有任何干扰.(所有连接字符串都位于.XML文件中,如:

 <databases>
    <type>Production
        <database>Database1</database>
        <database>Database2</database> …
Run Code Online (Sandbox Code Playgroud)

.net powershell package-managers visual-studio-2010

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

自定义Odata v4功能 - 不是有效的odata路由模板 - 未找到该段的资源

我有这样的想法(对自己的行动可能还行)

    [HttpPost]
    [ODataRoute("GenerateFromProduct")]
    public async Task<IHttpActionResult> GenerateFromProduct([FromBodyAttribute] Product product)
    {
        if(!ModelState.IsValid)
        {
            return BadRequest();
        }

        List<string[]> combos = new List<string[]>();
        List<ProductVariant> productVariants = product.GenerateProductVariants();
        db.ProductVariants.AddRange(productVariants);

        await db.SaveChangesAsync();

        return Ok(productVariants);
    }
Run Code Online (Sandbox Code Playgroud)

WebApiConfig中定义的操作可能是这样的:

 builder.EntityType<ProductVariant>().Collection
 .Function("GenerateFromProduct").Returns<List<ProductVariant>>().EntityParameter<Product>("product");
Run Code Online (Sandbox Code Playgroud)

但我不断收到以下错误(几次重写后)

An exception of type 'System.InvalidOperationException' occurred in System.Web.OData.dll but was not handled in user code

Additional information: The path template 'GenerateFromProduct' on the action 'GenerateFromProduct' in controller 'ProductVariants' is not a valid OData path template. Resource not found for the segment 
Run Code Online (Sandbox Code Playgroud)

我有什么想法吗?我没有在网上找到很多关于odata和自定义函数/动作的信息,除了msdn上的信息.

.net asp.net-mvc odata asp.net-web-api odata-v4

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

K ef command gives "k : System.Exception: Unable to locate project.json "

When i try to add a migration, "k" gives me the following error:

k : System.Exception: Unable to locate project.json
At line:1 char:1
+ k web
+ ~~~~~
+ CategoryInfo          : NotSpecified: (System.Exceptio...te project.json:String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError

bij Microsoft.Framework.Runtime.DefaultHost.Initialize(DefaultHostOptions options, IServiceProvider hostServices)
bij Microsoft.Framework.Runtime.DefaultHost..ctor(DefaultHostOptions options, IService
Provider hostServices)
bij Microsoft.Framework.ApplicationHost.Program.Main(String[] args)
Run Code Online (Sandbox Code Playgroud)

Here is my global.json:

{
"projects": [ "src", "FoodDelivery" ],
"sdk": {
    "version": "1.0.0-beta4"
    }
}
Run Code Online (Sandbox Code Playgroud)

I have the following directory structure

FoodPick
FoodPick/src
FoodPick/src/FoodDelivery
FoodPick/src/FoodDelivery/project.json …
Run Code Online (Sandbox Code Playgroud)

asp.net-mvc asp.net-core

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