I am trying to create a very basic test project to see if I can query content hub using linq as the documentation suggests and am having some trouble.

I have created a .net5 console application and added the StyleLabs.M.Sdk.WebClient 4.1.1 nuget package from a nuget source configured for https://slpartners.myget.org/f/m-public/api/v3/index.json.

For my first attempt, visual studio complains:

'Query' does not contain a definition for 'Take'...

I tried adding the StyleLabs.M.Querying.Linq nuget package, but when I attempt to add the package, package manager complains:

Unable to find package Sitecore.Quince.Utilities. No packages exist with this id in source(s) (...)

Next I tried adding StyleLabs.M.Base.Querying 3.3.26. This restored successfully, and Take was now accepted as an extension to Query. But instead, Query became the problem!

The type Query exists in both StyleLabs.M.Base.Querying and StyleLabs.M.Sdk

I'm tearing my hair out here. I already do have a project that uses the non-linq query methods, but I am attempting to follow the documentation's recommendation.

If I remove the WebClient namespaces I no longer get a conflict, but if I remove those namespaces then I don't have a client.. so... shrug!

using System;
using System.Linq;
using Q = Stylelabs.M.Base.Querying;
using Stylelabs.M.Base.Querying.Linq; // visual studio indicates this is not being used
using WCA = Stylelabs.M.Sdk.WebClient.Authentication;
using WC = Stylelabs.M.Sdk.WebClient;

internal class Program
    private static void  Main(string[] args)
        var grant = new WCA.OAuthPasswordGrant { /**/ };
        var client = WC.MClientFactory.CreateMClient(new Uri(""), grant);
        var query = Q.Query.CreateQuery(entities =>
           from e in entities
           select e).Take(10); 


With only the StyleLabs.M.Sdk.WebClient 4.1.1 package added, I get

'Query' does not contain a definition for 'Take' and no accessible extension method 'Take' accepting a first argument of type 'Query' could be found (are you missing a using directive or an assembly reference?)

With the StyleLabs.M.Sdk.WebApiClient 3.1.4 also added, I get

The type 'Query' exists in both 'Stylelabs.M.Base.Querying, Version=, Culture=neutral, PublicKeyToken=null' and 'Stylelabs.M.Sdk, Version=, Culture=neutral, PublicKeyToken=null'

Help? Ideally, what I'd like is a list of the very first few steps to follow once I have, say, a bare console application created. Like:

  1. Add the insert specific package name and version here nuget package.
  2. Add the insert another specific name and version here nuget package
  3. ...
  4. Add using ...
  5. call MClientFactory.CreateMClient(..)
  6. Create the query object using Query.CreateQuery(...)
  • Without seeing all your using statements, its hard to know the actual problem. But my guess is that one of your using namespaces is giving you the wrong Query static object or you don't have the required using statement that contains the CreateQuery extension method.
    – Richard Seal
    Sep 27, 2021 at 14:01
  • @RichardSeal Cheers. The original usings are as per the linked doc, I have added them to the question. I think I have an idea of what's going on here... this seems to be related to the usage of IWebMClient vs IMClient. My existing (non linq) solution uses IWebMClient. There may also be issues created by package versioning... I have the latest stable for all of the packages, but if I downgrade webclient to 3.. I get different behaviour.
    – allmhuran
    Sep 27, 2021 at 14:21

1 Answer 1


Looking at the Query object, it only has a Take property available. It's not an IQuerable that you create with Query.CreateQuery. Therefore you can't use LINQ method TAKE, to set the property.

That said, you could of course always use extension methods for this purpose.

public static class QueryExtensions
    public static Query Take(this Query query, int take)
        query.Take = take;

        return query;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.