I have been working with the TFS API for VS2010 and had to query FieldCollection which I found isn\'t supported by LINQ so I wanted to create a custom class to make the Field an
In your case of wrapping and building a class around an existing IEnumerable Collection type i.e. List
,
you might just use a set of "forward function" wrappers that expose the IQueryable
interface:
public class WorkItemFieldCollection : IEnumerable, IQueryable
{
...
#region Implementation of IQueryable
public Type ElementType
{
get
{
return this._fieldList.AsQueryable().ElementType;
}
}
public Expression Expression
{
get
{
return this._fieldList.AsQueryable().Expression;
}
}
public IQueryProvider Provider
{
get
{
return this._fieldList.AsQueryable().Provider;
}
}
#endregion
...
}
You can now directly query your WorkItemFieldCollection
:
var workItemFieldCollection = new WorkItemFieldCollection(...);
var Fuzz = "someStringId";
var workFieldItem = workItemFieldCollection.FirstOrDefault( c => c.Buzz == Fuzz );