I am trying to write a generic method to check to see if an item is in an MList before adding it and also to check and initialize the MList if it has not yet been initialized.
Here is my code:
list, T item)
//Get count of items in list.
int numItems = list.Count<T>();
//IF count=0, THEN init list.
//IF item not in list, THEN add item to list.
int matchingItems =
Database.Query<T>().Count<T>(i => i.RefName == item.RefName);
if (matchingItems == 0)
//add item to list
//Save list parent object.
This is the error message that I am getting:
The type 'T' cannot be used as type parameter 'T' in the generic type or method 'Signum.Engine.Database.Query<T>()'. There is no boxing conversion or type parameter conversion from 'T" to 'Signum.Entities.IdentifiableEntity'.
Has the Query method of Database not been programmed to handle a generic parameter? Do I have to handle this sort of conversion myself?
Perhaps there is something else wrong with my approach? Any help you can provide here will be greatly appreciated. (All my entities use a unique RefName to help me know which instance of a given class is being handled.)