Given the following Enum:
[Flags]
public enum CheeseCharacteristic
{
Yellow = 1,
Stinks = 2,
Squeaks = 4,
Holey = 8,
Mouldy = 16,
UseOnToast = 32
}
And an entity Cheese having the property Characteristic, is it possible to order Cheeses based on how many flags are matched against the Characteristic? For example, say a Stilton has the Characteristic value Yellow, Stinks, Mouldy and a MildCheddar has the Characteristic value Yellow, UseOnToast, is it possible to order by the number of matches for a given query?
So if I want to compare a collection of Cheese entities against Yellow, Mouldy then both Stilton and MildCheddar are returned, but the Stilton is top of the list as it has 2 matches.
To take this further, if I store the enum value in SQL Server, can I perform this sort in the DB using EF Core?