Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3941984
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T00:36:30+00:00 2026-05-20T00:36:30+00:00

I have a tool that generate entities I need to generate a samlpe value

  • 0

I have a tool that generate entities I need to generate a samlpe value for testing. the problem is that we have alot of logical types (some of the same type but still different) and befor coding i wanted to know if someone have a easier solution…

Here is the Enum :

public enum LogicalTypeEnum
    { 
        Identity,
        DateAndTime,
        Binary,
        Quantity,
        Comment,
        Money,
        Rate,
        TimeStamp,
        Caption,
        Reference,
        Number,
        Weight,
        Space,
        Username,
        Phone,
        Email,
        ZipCode
    }

Thanks!!!

EDIT 1: I want to generate a random value not get a random element from the enum. I’m searching a way to get a random email or zipcode or money value.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T00:36:31+00:00Added an answer on May 20, 2026 at 12:36 am

    I think you have to divide your answer into two parts:

    First get a random enum type out of the list. I think this part is already solved by the other answers provided.

    Afterwards you like to create a list of random values for the selected enum. So you need a factory that can create a valid random value for each of these types. The thing that come closest to your needs should be AutoPoco. It is quite easy to create a bunch of sample object filled up with some values you like for example

    var factory = AutoPoco.AutoPocoContainer.Configure(x =>
    {
        x.Conventions(c =>
        {
            c.UseDefaultConventions();
        });
    
        x.Include<DataRowWrapper>()
            .Setup(row => row.Timestamp).Use<DateTimeUniqueSource>()
            .Setup(row => row.Name).Use<LastNameSource>()
            .Setup(row => row.Value).Use<ApproximateNumberSource<decimal>>()
            .Setup(row => row.Description).Use<RandomReadableStringSource>(10, 20);
    });
    
    var session = factory.CreateSession();
    var sampleRows = session.List<DataRowWrapper>(1000).Get();
    

    As you can see you can provide for each property your own Source (.Use<...Source>()).
    There are already some default sources within the project but i also made some on my own like the following:

    public class RandomReadableStringSource : DatasourceBase<string>
    {
        private readonly char[] _Vocals = new char[] { 'a', 'e', 'i', 'o', 'u' };
        private readonly char[] _Consonants = new char[] { 'b', 'c', 'd', 'f', 'g', 'h', 'k', 'l', 'm', 'n', 'p', 'r', 's', 't', 'v', 'w' };
    
        private Random _Random;
        private int _Minimum;
        private int _Maximum;
    
        public RandomReadableStringSource()
            : this(20)
        { }
    
        public RandomReadableStringSource(int max)
            : this(5, max)
        { }
    
        public RandomReadableStringSource(int min, int max)
        {
            if (min <= 0)
            {
                throw new ArgumentOutOfRangeException("minimum must be greater zero.");
            }
    
            if (min > max)
            {
                throw new ArgumentOutOfRangeException("minimum must be less or equal maximum.");
            }
    
            _Random = new Random();
            _Minimum = min;
            _Maximum = max;
        }
    
        public override string Next(IGenerationSession session)
        {
            var length = _Random.Next(_Minimum, _Maximum);
            var sb = new StringBuilder(length);
    
            for (int i = 0; i < length; i++)
            {
                var array = i % 2 == 0 ? _Consonants : _Vocals;
                sb.Append(array[_Random.Next(array.Length)]);
            }
    
            return sb.ToString();
        }
    }
    
    public class DateTimeUniqueSource : DatasourceBase<DateTime>
    {
        private Random _Random;
        private DateTime _LastDateTime;
    
        public DateTimeUniqueSource()
            : this(new DateTime(1900, 1, 1))
        { }
    
        public DateTimeUniqueSource(DateTime startdate)
        {
            if (startdate == null)
            {
                throw new ArgumentNullException("startdate");
            }
    
            _Random = new Random();
            _LastDateTime = startdate;
        }
    
        public override DateTime Next(IGenerationSession session)
        {
            _LastDateTime = _LastDateTime.AddHours(_Random.NextDouble() * 1000);
            return _LastDateTime;
        }
    }
    

    So you could create your own source for each type and afterwards quite easy create a bunch of sample objects.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have to develop a tool in C# that retrieves some data from an
I need to generate and send SyncML OTA SMS. I have sms provider that
I have a tool that I want to install on my main development box
Right now, I have a tool tip that pops up when I hover over
I have the following situation: There is a tool that gets an XSLT from
I have been thinking of maybe writing a little tool that logs into SO
My group has a source analysis tool that enforces certain styles that we have
I have a bunch of <5 matlab scripts. Is there a tool that can
Do any of the IDEs (or any other tool for that matter) have the
I have a SOAP request that is known to work using a tool like,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.