I am trying to generate 3000 fake records in C# with condition that each 1000 items will have same time stamp(update_time) in UTC milliseconds, then next 1000 will have same time stamp in UTC milliseconds. how to achieve that? #376
Answered
by
bchavez
mehulparmariitr
asked this question in
Q&A
-
I am trying to generate 3000 fake records in C# with condition that each 1000 items will have same time stamp(
|
Beta Was this translation helpful? Give feedback.
Answered by
bchavez
Jul 12, 2021
Replies: 1 comment
-
The following code seems to work: void Main()
{
var now = DateTimeOffset.UtcNow;
var documentFaker = new Faker<Document>()
.StrictMode(true)
.RuleFor(o => o.id, f => Guid.NewGuid().ToString())
.RuleFor(o => o.update_time, f =>
{
if (f.IndexFaker % 3 == 0) now = now.AddMilliseconds(10);
return now.ToUnixTimeMilliseconds().ToString();
});
var fakeDocuments = documentFaker.Generate(30);
fakeDocuments.Dump();
}
public class Document
{
public string update_time { get; set; }
public string id { get; set; }
} Every 3 generated documents, the |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
bchavez
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The following code seems to work:
Every 3 generated documents, the
update_time
is updated +10 millise…