LinqExtensions.cs 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. /* Copyright 2016-present MongoDB Inc.
  2. *
  3. * Licensed under the Apache License, Version 2.0 (the "License");
  4. * you may not use this file except in compliance with the License.
  5. * You may obtain a copy of the License at
  6. *
  7. * http://www.apache.org/licenses/LICENSE-2.0
  8. *
  9. * Unless required by applicable law or agreed to in writing, software
  10. * distributed under the License is distributed on an "AS IS" BASIS,
  11. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. * See the License for the specific language governing permissions and
  13. * limitations under the License.
  14. */
  15. using System;
  16. using System.Collections.Generic;
  17. using System.Linq;
  18. using System.Text;
  19. using System.Threading.Tasks;
  20. namespace MongoDB.Driver.Linq
  21. {
  22. /// <summary>
  23. /// This static class holds methods that can be used to express MongoDB specific operations in LINQ queries.
  24. /// </summary>
  25. public static class LinqExtensions
  26. {
  27. /// <summary>
  28. /// Injects a low level FilterDefinition{TDocument} into a LINQ where clause. Can only be used in LINQ queries.
  29. /// </summary>
  30. /// <typeparam name="TDocument">The type of the document.</typeparam>
  31. /// <param name="filter">The filter.</param>
  32. /// <returns>
  33. /// Throws an InvalidOperationException if called.
  34. /// </returns>
  35. public static bool Inject<TDocument>(this FilterDefinition<TDocument> filter)
  36. {
  37. throw new InvalidOperationException("The LinqExtensions.Inject method is only intended to be used in LINQ Where clauses.");
  38. }
  39. }
  40. }