public static Translate ( MongoCollection collection, |
||
collection | MongoCollection | The collection being queried. |
expression | The LINQ query. | |
return |
// public methods /// <summary> /// Builds the MongoDB query that will be sent to the server when the LINQ query is executed. /// </summary> /// <typeparam name="T">The type of the documents being queried.</typeparam> /// <param name="query">The LINQ query.</param> /// <returns>The MongoDB query.</returns> public IMongoQuery BuildMongoQuery <T>(MongoQueryable <T> query) { var translatedQuery = MongoQueryTranslator.Translate(this, ((IQueryable)query).Expression); return(((SelectQuery)translatedQuery).BuildQuery()); }
/// <summary> /// Gets a string representation of the LINQ expression translated to a MongoDB query. /// </summary> /// <param name="expression">The LINQ expression.</param> /// <returns>A string.</returns> public string GetQueryText(Expression expression) { var translatedQuery = MongoQueryTranslator.Translate(_collection, expression); return(translatedQuery.ToString()); }