尝试将数据绑定到下拉列表,但不绑定任何内容,下拉列表显示 NOTHING SELECTED.
<select #classProductTypeCombobox
name="classProductTypeCombobox"
class="form-control col-md-3"
[(ngModel)]="classification.codeType"
[attr.data-live-search]="true"
jq-plugin="selectpicker"
required>
<option *ngFor="let classType of classificationTypes"
[value]="classType">{{classType}}</option>
</select>
Run Code Online (Sandbox Code Playgroud)
角度代码:
getClassificationTypes(): void {
//need to remove hard coding
this._commonService.getLookupItems(1, 6).subscribe((result) => {
this.classificationTypes= result.items;
});
}
ngOnInit(): void {
this.getClassificationTypes();
}
Run Code Online (Sandbox Code Playgroud)
当我尝试调试代码时,classificationTypes
有适当的数据,我用作硬编码值的相同数据.它工作正常.
方法getClassificationTypes
是调用API从数据库中获取数据.
我正在使用ASP.NET Zero框架编写此应用程序.
我尝试了以下解决方案.这是将数据绑定到下拉列表,但是下拉列表的自动搜索功能已经消失,它显示简单的下拉列表.并在控制台中,它提供以下错误消息.
getClassificationTypes(): any {
return this._commonService.getLookupItems(2, 6).subscribe((result) => {
console.log(result.items)
return this.classificationTypes = result.items;
});
}
classificationTypes: TaxonomyItemsLocDto[] = this.getClassificationTypes();
ERROR Error: Cannot find a differ supporting object '[object Object]' …
Run Code Online (Sandbox Code Playgroud) 我必须调用一个从多个表中选择记录的存储过程。
我尝试了以下代码,但它为实体类以外的其他表中的列返回 null。
private async Task<IEnumerable<TEntity>> InvokeStoredProcedureAsync(string input = "")
{
var storedProcedureName = "sp_BulkSelect";
using (var db = new MyDbContext(_options))
{
var result = await db.Set<TEntity>().FromSql(storedProcedureName + " @inputIds", new SqlParameter("inputIds", input)).ToListAsync();
return result;
}
}
Run Code Online (Sandbox Code Playgroud)
存储过程:
SELECT
[MainTable].[Id],
[Table1Id],
[Table2Id],
[MainTable].[Table1Code],
[Table2].[Table2Code]
FROM
[MainTable] [MainTable]
LEFT JOIN
[Table1] [Table1] ON [MainTable].Table1Id = [Table1].[Id]
LEFT JOIN
[Table2] [Table2] ON [MainTable].[Table2Id] = [Table2].[Id];
Run Code Online (Sandbox Code Playgroud)
MainTable
班级:
[Table("MainTable")]
public class MainTable : FullAuditedEntity
{
[ForeignKey("Table1Id")]
public virtual Table1 Table1 { get; set; …
Run Code Online (Sandbox Code Playgroud) c# entity-framework ef-code-first entity-framework-core asp.net-core
我不确定这个主题是否真的有意义,但我不确定如何说出来.这是设置:我有一个Item
,有很多ItemLogic
,每个都有一个Field
.Item
例如,每个ItemLogic
实体都有25个实体.逻辑确定是否Item
匹配表单中的给定输入.例如,Field X has a value greater than A
和Field Y has a value equal to B
等每个25场.
在当前版本的应用程序中,查询并循环所有相关实体,返回所有ItemLogic所在的第一个匹配项true
.它有点贵,但代码简单,而且从来没有那么多项目要看.到现在.
现在,该应用需要过滤3000个项目才能找到匹配项.上一个查询至少有两个连接,在我们的SQL实例上大约需要45秒.这太长了.
存储过程看起来很自然,但这里有一个问题:数据对于每组Items都是动态的,它以字符串值的形式出现,并且通常需要被转换为不同的类型(DateTime或int最常见)来执行实际的比较,一些逻辑被忽略而不是比较.这是存储过程中的大量额外开销,至少它是如何打击我的.
或者,我可以对数据进行分块,但这对于试图匹配集合中最后一个项目的可怜人来说并没有太大的节省.
有什么方法可以加速比赛?
架构和一些示例数据:
CREATE TABLE [dbo].[Items](
[Id] [int] IDENTITY(1,1) NOT NULL,
[Name] [nvarchar](255) NOT NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
CREATE TABLE [dbo].[ItemLogic](
[Id] [int] IDENTITY(1,1) NOT NULL,
[ItemId] [int] NOT NULL,
[FieldId] [int] NOT NULL,
[Value] [nvarchar](max) NULL,
[Comparison] [int] NOT NULL
) …
Run Code Online (Sandbox Code Playgroud) 我想请求您帮助使用Bogus Faker。
我有这个
private readonly Faker _faker;
_faker = new Faker("fr");
List<string> _randomString = (List<string>)_faker.Make(3, () => _faker.Random.Word()); // OK
List<string[]> _randomStrinArray = (List<string[]>)_faker.Make(3, () => _faker.Random.Word()); // KO
Run Code Online (Sandbox Code Playgroud) 我已将令牌过期时间设置为 1 分钟,但 1 分钟后我没有收到 401 未经授权的错误。
启动.cs
.AddJwtBearer(options =>
{
options.TokenValidationParameters = new TokenValidationParameters
{
ValidateIssuer = true,
ValidateAudience = true,
ValidateLifetime = true,
ValidateIssuerSigningKey = true,
ValidIssuer = Configuration["Jwt:Issuer"],
ValidAudience = Configuration["Jwt:Issuer"],
IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(Configuration["Jwt:Key"]))
};
});
Run Code Online (Sandbox Code Playgroud)
代币生成方法:
var securityKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(_configuration["Jwt:Key"]));
var credentials = new SigningCredentials(securityKey, SecurityAlgorithms.HmacSha256);
int expiryMins = 1
var token = new JwtSecurityToken(_configuration["Jwt:Issuer"],
_configuration["Jwt:Issuer"],
null,
expires: DateTime.UtcNow.AddMinutes(expiryMins),
signingCredentials: credentials);
return new JwtSecurityTokenHandler().WriteToken(token);
Run Code Online (Sandbox Code Playgroud) 我通过以下方式在EF Core 2.0中调用存储过程.
private async Task<IEnumerable<TEntity>> InvokeStoredProcedureAsync(string entityName)
{
var storedProcedureName = string.Format(CultureInfo.InvariantCulture, "sp_{0}BulkSelect", entityName);
dynamic temp;
using (MyDbContext MyDbContext = new MyDbContext(_options))
{
MyDbContext.Database.OpenConnection();
DbCommand cmd = MyDbContext.Database.GetDbConnection().CreateCommand();
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = storedProcedureName;
using (var reader = cmd.ExecuteReader())
{
temp = reader.Cast<Task<IEnumerable<TEntity>>>();
}
}
return await temp;
}
Run Code Online (Sandbox Code Playgroud)
我需要转换DbDataReader
为Task<IEnumerable<TEntity>>
.
但是在尝试扩展temp变量以查看其值时,我收到此错误.
读取器关闭时无效尝试调用FieldCount.
请参阅随附的屏幕截图.
c# entity-framework entity-framework-core asp.net-core ef-core-2.0
我想从"数据"表中隔离"帐户"表,以便重用另一个应用程序.
我尝试使用.NET Core 2.0 + Angular模板,创建2个连接字符串,但是当创建另一个AbpDbContext时,我无法为上下文设置连接字符串.
在GitHub上使用多个DB上下文的示例使用.NET框架,而不是.NET核心,允许在dbcontext ctor上设置连接字符串.如何在.net core 2模板上执行此操作?
我的模型上有一些属性,我不想在迁移后在表中生成字段。
是否可以排除Entity Framework Core 迁移的属性?
我的模型是否有一个属性或一些 Fluent API 方法DbContext
?
.net c# entity-framework-core .net-core entity-framework-migrations
EF 核心 2.2
有这个界面:
public interface INotPersistingProperties
{
string MyNotPersistingPropertyA { get; set; }
string MyNotPersistingPropertyB { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
以及许多实现该接口的实体
public class MyEntity : INotPersistingProperties
{
public int Id { get; set; }
public string MyNotPersistingPropertyA { get; set; }
public string MyNotPersistingPropertyB { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
对于所有实现 INotPersistingProperties 的实体,是否有机会自动忽略这些属性(使用 Fluent API)?
我希望在 Azure DevOps 中查看用户在我的组织中的所有存储库中的提交。我看不到这样的选项可用。
我可以在 Azure DevOps 中看到以下选项,但它显示单个存储库中的提交。
我知道我们可以使用下面的 git 命令来查看单个存储库中的提交。
git log --author<AuthorName> --all ( or --branches)
Run Code Online (Sandbox Code Playgroud) c# ×6
asp.net-core ×4
.net-core ×3
.net ×2
angular ×1
azure-devops ×1
bogus ×1
ef-core-2.0 ×1
entity-framework-migrations ×1
faker ×1
git ×1
git-log ×1
jwt ×1
list ×1
sql-server ×1
string ×1
typescript ×1