I have the following model:
[Key]
public string Id { get; set; }
[IsSearchable]
public string Code{ get; set; }
[IsSearchable]
public string Name { get; set; }
[IsSearchable]
public string Address { get; set; }
[IsSearchable]
public string PostCode { get; set; }
[IsFilterable]
public int? Setting{ get; set; }
[IsFilterable, IsSortable]
public Location Location { get; set; }
I am comparing a model in a database with the above one, and want to check that the database model has the same attributes. Is there any way to find out the specific number of attributes without having to hard code them in? For example, this is the method I've written to check:
private bool CheckAttributeEquality(List<PropertyInfo>searchableAttributeProperties,
List<PropertyInfo> filterableAttributeProperties,
List<PropertyInfo> sortableAttributeProperties,
List<PropertyInfo> keyAttributeProperties)
{
if (searchableAttributeProperties.Count == 4 &&
filterableAttributeProperties.Count == 2 &&
sortableAttributeProperties.Count == 1 &&
keyAttributeProperties.Count == 1)
{
return true;
}
return false;
}
However I don't want to hard code these in, I want to make sure they match the attributes on my model? Can anyone help?