我的以下代码是项目验证部分的一部分。这段代码的目的是检查引用表中是否存在某个值。如果存在,则可以继续。如果不是,则抛出错误并停止用户。
saveChanges() {
//blah blah
if (needTovalidate){
passedCheck = false;
this.validationService.checkExistence(value)
.then((exist: boolean) => {
passedCheck = exist;
console.log("INSIDE: " + exist);
});
console.log("OUTSIDE: " + passedCheck);
if(passedCheck) {
//Rest of code
} else {
//Throw error msg
}
}
public async checkExistence(value: string): Promise<boolean>{
var exist = false;
return this.getRefData().then((rec: dataModel[]) => {
return rec.some(el => {
return el.col1 === value;
});
});
}
private async getRefData() {
return await this.configurationService.retrieveTableData().toPromise();
}
Run Code Online (Sandbox Code Playgroud)
预期日志:
INSIDE: true
OUTSIDE:true
Run Code Online (Sandbox Code Playgroud)
实际日志:
OUTSIDE: false …Run Code Online (Sandbox Code Playgroud) 我在我的 Angular 项目中使用 Ag-grid。
下面是代码:
var displayModel = this.gridOptions.api.getModel();
var rowNode = displayModel.rowsToDisplay[params.rowIndex];
Run Code Online (Sandbox Code Playgroud)
错误被抛出rowsToDisplay
TS2339: Property 'rowsToDisplay' does not exist on type 'IRowModel'.
Run Code Online (Sandbox Code Playgroud)
我能够成功运行它,但无法编译。
我错过了导入任何东西吗?我正在使用 v17 的 ag-grid 社区版本。
分享一些背景
我使用 rowsToDisplay,因为我想在排序后按索引获取行数据。原版gridOptions.api.getRowNode对我不起作用,因为它没有考虑sorting哪个会重新排列索引号...如果我错了,请纠正我。
根据这篇文章,票数最高的答案表明我们可以直接在main中使用async。还是我误会了?
我的主班:
public class Program
{
public static async Task Main(string[] args)
{
ApproveEvents ap = new ApproveEvents();
List<MyModel> result = new List<MyModel>();
result = await ap.ApproveAsync();
if (result.count > 0)
{
//do something here
}
}
}
Run Code Online (Sandbox Code Playgroud)
和,
public class ApproveEvents
{
public async Task<List<MyModel>> ApproveAsync()
{
//blah blah
}
}
Run Code Online (Sandbox Code Playgroud)
Visual Studio 2017抱怨no Main method for an entry point。
我该如何解决?
我得到一个结果 DataFrame,其列类型为Int64.
我怎样才能将它转换为int64?
下面的代码不起作用。
print(region_ids.mycolumn.dtypes)
region_ids['mycolumn'].astype(int64)
print(region_ids.mycolumn.dtypes)
Run Code Online (Sandbox Code Playgroud)
实际结果:
Int64
Int64
Run Code Online (Sandbox Code Playgroud)
预期结果:
Int64
int64
Run Code Online (Sandbox Code Playgroud) 我知道它看起来很简单,但我花了很多时间在这上面.
不知怎的,我无法成功返回列表...
public Task<List<MyViewModel>> getGoodElections(long actionId)
{
var elections = _DBsource.ElectionTable.Where(e => e.ActionId == actionId && e.Status == "OK").ToListAsync();
List< MyViewModel > list = Mapper.Map<List<MyViewModel>>(elections);
return list;
}
Run Code Online (Sandbox Code Playgroud)
在"返回列表;",它给了我错误:
无法隐式转换
System.Collections.Generic.List<MyViewModel>为System.Threading.Tasks.Task<System.Collections.Generic.List<MyViewModel>>
有任何想法吗?