I'm just wondering. Is it possible in fluent api or anything that an Enum
type would be mapped as tinyint
?
Say for example,
public enum PaperType
{
Rough=1,
Smooth=2,
}
public class TestPaper
{
public PaperType PaperType { get; set; }
}
And if run migration correctly, it will mapped to an int
which is not I don't want. I want to assigned tinyint
so that it would not take much as space. int 4bytes
while tinyint 1byte
Any thoughts? Thanks!
You can do:
public enum PaperType : byte
{
Rough=1,
Smooth=2,
}
But don't do that, that is premature optimization. Only come to optimization like these if there is a problem in your application performance. (default under laying type of enum
is int
so I am not sure if having a byte
as enum type would save you anything, it will be treated as int
. It might be useful if you are planning to use an array of enum
, in that case you will get byte[]
)
I'm not sure that's what you are asking for:
public enum PaperType : byte
{
Rough=1,
Smooth=2,
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With