我现在开始使用Angular2工作,并对框架ng2-charts有疑问.
这是我的component.ts代码:
import { Component } from '@angular/core';
import { ChartsModule } from 'ng2-charts';
import { PredictionService } from './prediction.service'
@Component({
selector: 'prediction-result-chart',
templateUrl: './predictionResultChart.component.html'
})
export class PredictionResultChartComponent{
public pieChartLabels:string[] = [];
public pieChartData:number[] = [];
public pieChartType:string = 'pie';
public JSONobject = {}
constructor(private predictionService: PredictionService){
this.getPredictions();
}
public getPredictions() {
this.predictionService.getPredictions('hello').do(result => this.populateChart(result)).subscribe();
}
public populateChart(obj): void{
let labels:string[] = [];
let data:number[] = [];
for (var i = 0; i …Run Code Online (Sandbox Code Playgroud) 我的数据库中有一个用户表,其中包含"全名"字段
在我的工具上,我上传了一些文件,然后在数据库中插入数据之前,我通过比较数据库中的全名字段和文件上的全名字段来检查用户是否存在(这是唯一的选项,我无法比较ids).
我的问题是:当这些字段包含两个以上的字时,如何比较这些字段?
有时全名不符合规定,例如:
-------------------------------------------------
| Database || File |
-------------------------------------------------
| Michael Yves Pierrot || Pierrot Michael Yves |
| Martin Dupont || Dupont Martin |
| Ben Jack Dupont || Ben Dupont Jack |
-------------------------------------------------
Run Code Online (Sandbox Code Playgroud)
当只有两个单词时,我就可以使用这样的分割:
public string getId()
{
string result;
QueryModel Query = new QueryModel();
string sql = "SELECT Username_Id FROM USERNAME WHERE Full_name = '"
+ Full_name.Replace("'", "''") + "'";
result = Query.ExecuteCommand(sql, "int");
if (result != "0")
{
string FullName2 = Full_name.Split(' ')[1] + …Run Code Online (Sandbox Code Playgroud) 我有字符串,如果它匹配这个正则表达式我想要翻译:
正则表达式应为3个大写字母后跟" - "和两个或多个单词然后()
示例:
BEN - Two Words (m738783)
TST - THREE Words test (a187817)
Run Code Online (Sandbox Code Playgroud)
我试过这个正则表达式
Regex userRegex = new Regex(@"^[A-Z]3-[A-Za-z]+([A-Za-z0-9])$");
Run Code Online (Sandbox Code Playgroud)
但它不起作用,有人可以帮忙吗?
我是正则表达式的新手.
谢谢.
我正在使用AngularJS、ASP.NET、实体框架和SQL Server数据库开发一个 Web 应用程序。
我想通过此方法使用EF插入一些行:
public string addRow(int CaptionID, string enLang)
{
string output = "";
try
{
var Cap = new Table_Name();
string userName = System.Security.Principal.WindowsIdentity.GetCurrent().Name;
Cap.CodeId = CaptionID;
Cap.Created = DateTime.Now;
Cap.CreatedBy = userName;
Cap.ID = "";
Cap.CodeLanguage = "en";
Cap.CodeCountry = "GB";
Cap.Caption = enLang;
_db.Entry(Cap).State = EntityState.Added;
_db.SaveChanges();
output = "Created";
}
catch (Exception ex)
{
output = ex.InnerException.Message;
}
return output;
}
Run Code Online (Sandbox Code Playgroud)
这个功能有效。
但我对这个函数有一个疑问NEWID(),我已经搜索了很多以知道如何重现相同的内容,但我不知道,我看过这个 …
我正在尝试使用Python排序JSON对象。
我有以下对象:
{
"text": "hello world",
"predictions":
[
{"class": "Class 1", "percentage": 4.63},
{"class": "Class 2", "percentage": 74.68},
{"class": "Class 3", "percentage": 9.38},
{"class": "Class 4", "percentage": 5.78},
{"class": "Class 5", "percentage": 5.53}
]
}
Run Code Online (Sandbox Code Playgroud)
我想拥有这个对象:
{
"text": "hello world",
"predictions":
[
{"class": "Class 2", "percentage": 74.68},
{"class": "Class 3", "percentage": 9.38},
{"class": "Class 4", "percentage": 5.78},
{"class": "Class 5", "percentage": 5.53},
{"class": "Class 1", "percentage": 4.63}
]
}
Run Code Online (Sandbox Code Playgroud)
实际上,我想按百分比排序对象数组。
我已经尝试过以下命令:
sorted_obj = sorted(json_obj['predictions'], key=lambda k: …Run Code Online (Sandbox Code Playgroud) c# ×3
sql-server ×2
angular ×1
asp.net ×1
asp.net-mvc ×1
chart.js ×1
charts ×1
database ×1
javascript ×1
json ×1
ng2-charts ×1
python ×1
regex ×1
sorting ×1