I need to store a boolean matrix like this:
public bool[][] Schedule { get; set; }
It's basically a schedule that is to be applied as follows in the view:
It works in the view but I can't store it properly with Entity Framework, since it doesn't even create the Tables upon a migration. How can I store it?
In terms of actual storage of this information in the database, a format like the following would work:
Type Database table (optional, with use of enum)
Id Type
1 Segunda
2 Terca
3 Quarta
4 Sexta
Values Database table
Id TimeFrom TimeTo TypeId Selected
1 8:00 9:00 1 1
2 8:00 9:00 2 1
3 8:00 9:00 3 1
4 8:00 9:00 4 1
5 8:00 9:00 5 1
6 9:00 10:00 1 0
7 9:00 10:00 2 0
8 9:00 10:00 3 1
9 9:00 10:00 4 0
10 9:00 10:00 5 0
11 10:00 11:00 1 1
12 10:00 11:00 2 1
13 10:00 11:00 3 1
14 10:00 11:00 4 1
15 10:00 11:00 5 1
The following domain objects would support this layout of storage, for example:
public enum TypeEnum
{
Segunda = 1,
Terca = 2,
Quarta = 3,
Sexta = 4
}
public class Type
{
public int Id { get; set; }
public TypeEnum Type { get; set; }
}
public class Schedules
{
public int Id { get; set; }
public DateTime TimeFrom { get; set; }
public DateTime TimeTo { get; set; }
public TypeEnum TypeId { get; set; }
public bool Selected { get; set; }
}
You could extrapolate the times from and to into another table if you're storing this information for multiples users or just to normalise the data.
It should be easy to map these values to a suitable view model to be mapped back and forth from the view.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.