Reputation: 223
Im trying to seed my database with Faker.net because I need a lot of data generated, is it possible to set the phone numbers to only create 11 numbers long?
var addresses = Builder<deliveryAddress>.CreateListOfSize(40)
.All()
.With(c => c.FirstName = Faker.Name.First())
.With(c => c.LastName = Faker.Name.Last())
.With(c => c.Address = Faker.Address.StreetAddress())
.With(c => c.City = Faker.Address.City())
.With(c => c.Country = Faker.Address.UkCountry())
.With(c => c.PostalCode = Faker.Address.UkPostCode())
.With(c => c.Mobile = Faker.Phone.Number().)
.With(c => c.Phone = Faker.Phone.Number())
.Build();
context.deliveryAddresses.AddOrUpdate(c => c.AdressId, addresses.ToArray());
Upvotes: 0
Views: 101
Reputation: 11
Based on Faker.NET
source code, Faker.Phone.Number()
can take a parameter. You can pass the pattern string like "###-####-#####"
as a parameter to Faker.Phone.Number(string pattern)
.
Saw your question on the phone, haven't got chance to test it.
Upvotes: 1
Reputation: 851
Use String format to limit your string Characters.
Ex. String.Format("{0:(###) ###-####}", 9912345678);
This will output "(991) 234-5678".
Or also you can try:
const int MaxLength = 11; var name = "1234567910123456";
if (name.Length > MaxLength)
name = name.Substring(0, MaxLength); // name = "12345678910"
or Refer this trik.
Upvotes: 0