伪造的模拟数据相同的值对于 2 个不同的属性,是否可以让 2 个属性在 fluent api 中具有相同的值。
var users = new Faker<User>()
.StrictMode(false)
.RuleFor(o => o.Id, f => orderIds++)
.RuleFor(o => o.UserName, f => f.Person.FullName) // This needs to be same as the next property
.RuleFor(o => o.NormalizedUserName, f => f.Person.FullName) // This should be same but uppercase
想要生成的数据:
[
{
userName: "Ivan Horvat",
normalizedUserName: "IVAN HORVAT"
},
{
userName: "John Doe",
normalizedUserName: "JOHN DOE"
}
]
我希望生成的每个实体都具有相同的实体UserName
,NormalizedUsername
但每个实体都有自己的实体。