Currently, I have this code, which works, getting a foodList:
var myDictionary = new System.Collections.Generic.Dictionary<string, object>();
myDictionary .Add("RefId",1);
myDictionary.Add("Type", "fruit");
var foodList = this.factoryService.GetMyService()
.GetByCriteria(sortOrder, NHibernate.Criterion.Restrictions.AllEq(myDictionary));
I want to use MultiValueDictionary so as to gather more than one Type.
var multiValueDictionary = new System.Collections.Generic.MultiValueDictionary<string, object>();
multiValueDictionary.Add("RefId",1);
multiValueDictionary.Add("Type", "fruit");
multiValueDictionary.Add("Type", "vegetable");
multiValueDictionary.Add("Type", "fungus");
var foodList = this.factoryService.GetMyService()
.GetByCriteria(sortOrder, NHibernate.Criterion.Restrictions.AllEq(multiValueDictionary));
That last line doesn't compile because MultiValueDictionary does not implement IDictionary, giving the error:
Error CS1503 Argument 1: cannot convert from 'System.Collections.Generic.MultiValueDictionary' to 'System.Collections.IDictionary'
How can I do this?
AllEq
implementation is simply:So for your multi-value case, you could cease putting it in the dictionary and manually add it afterward:
Of course if you now only have
RefId
to put in your dictionary, better simplify it:Now if you want an
AllIn
handling multi-values, code it: