title: How To run LINQ queries with Type of <T>
body: <p>This is My Class which is basically Closed Coupled To Type  I want to Generalise this Class.</p>
  <p>So I can use with all the Class</p>
  <p>one thing is common that there will be a Name field while invoking this method</p>
  <pre><code>    public class CustomSuggestionProvider : ISuggestionProvider
      {
          private const int batchSize = 30;
          private string _criteria = string.Empty;
          private int _skipCount;
  
          private readonly ObservableCollection&lt;LanguageItem&gt; _observableCollection;
          private readonly List&lt;LanguageItem&gt; _source;
  
          public CustomSuggestionProvider(ObservableCollection&lt;LanguageItem&gt; observableCollection, List&lt;LanguageItem&gt; source)
          {
              _observableCollection = observableCollection;
              _source = source;
          }
  
          public bool HasMoreSuggestions { get; private set; } = true;
  
          public Task&lt;IList&lt;object&gt;&gt; GetSuggestionsAsync(string criteria, CancellationToken cancellationToken)
          {
              _criteria = criteria;
              var newItems = _source.Where(x =&gt; x.Name.IndexOf(_criteria, StringComparison.OrdinalIgnoreCase) &gt;= 0).ToList();
              if (cancellationToken.IsCancellationRequested)
                  return null;
              HasMoreSuggestions = newItems.Count &gt; batchSize;
              _skipCount = batchSize;
              return Task.FromResult&lt;IList&lt;object&gt;&gt;(newItems.Take(batchSize).Cast&lt;object&gt;().ToList());
          }
  
       
      }
  </code></pre>
  <p>I Just made it Generalised like this.</p>
  <p>Made all the closely coupled class to Type T.</p>
  <p>Kindly have a look.</p>
  <pre><code> public class CustomSuggestionProvider&lt;T&gt; :  ISuggestionProvider
      {
          private const int batchSize = 30;
          private string _criteria = string.Empty;
          private int _skipCount;
          
          private readonly ObservableCollection&lt;T&gt; _observableCollection;
          private readonly List&lt;T&gt; _source;
  
          public CustomSuggestionProvider(ObservableCollection&lt;T&gt; observableCollection, List&lt;T&gt; source)
          {
              _observableCollection = observableCollection;
              _source = source;
          }
   
  
          public bool HasMoreSuggestions { get; private set; } = true;
  ]
  
  
          public Task&lt;IList&lt;object&gt;&gt; GetSuggestionsAsync(string criteria, CancellationToken cancellationToken)
          {
              _criteria = criteria;
                  var newItems = _source.Where(x =&gt;Name.IndexOf(_criteria, StringComparison.OrdinalIgnoreCase) &gt;= 0).ToList();
              if (cancellationToken.IsCancellationRequested)
                  return null;
              HasMoreSuggestions = newItems.Count &gt; batchSize;
              _skipCount = batchSize;
              return Task.FromResult&lt;IList&lt;object&gt;&gt;(newItems.Take(batchSize).Cast&lt;object&gt;().ToList());
          }
  
          public Task&lt;IList&lt;object&gt;&gt; GetSuggestionsAsync(CancellationToken cancellationToken)
          {
              var newItems = _source.Where(x =&gt; x.Name.StartsWith(_criteria)).Skip(_skipCount).ToList();
              if (cancellationToken.IsCancellationRequested)
                  return null;
              HasMoreSuggestions = newItems.Count &gt; batchSize;
              _skipCount += batchSize;
              return Task.FromResult&lt;IList&lt;object&gt;&gt;(newItems.Take(batchSize).Where(x =&gt; !_observableCollection.Any(y =&gt; y.Id == x.Id)).Cast&lt;object&gt;().ToList());
          }
      }
  </code></pre>
  <p>I just stuck when at this statement</p>
  <p>The 'Name' does not exist here</p>
  <pre><code>var newItems = _source.Where(x =&gt; x.Name.IndexOf(_criteria, StringComparison.OrdinalIgnoreCase) &gt;= 0).ToList();
  
  </code></pre>
  <p>Can you please help troubleshoot this.</p>
  <p>Thanks in Advance.</p>