I am trying to map a property to the database. However it is a list/array for which I know the fixed length. So I would like those items to be mapped into the same database table without needing to be mapped into a different database table.
public class Recurrency{
public int Id { get; set; }
public DateTime BeginDate { get; set; }
public DateTime EndDate { get; set; }
public Boolean[] IsRecurrent { get; set; }
}
The Boolean array I am currently using is as long as the days of the week and should be accessed using the DaysOfWeek enumerator already provided.
Any ways of solving this?
Instead of using a Boolean array, you could use an enum.
In your database DaysOfWeek would be stored as an integer. That integer would map to the true/false for each day of the week.
For example DaysOfWeek == 22, would be (Monday, Tuesday, and Thursday). Or if you thought of it as an array of booleans (false (1), true (2), true (4), false (8), true (16), false (32), false (64))
To set the IsRecurrent you can use the bitwise (|) to combine days.
And then to query the values you could is the HasFlag method.