score:0
Accepted answer
thx.
i slove it like this:
var query1 = query.eq("comments.status", 1)
ienumerable<comment> comments = collection.distinct<comment>("comments", query1).where(x => x.status == 1);
comments .tolist() // <= list of comments with status 1
if someone has a better solution please post it.
thx again,
benjamin
score:2
let's assume you have the following classes that contain the serialized values for your collection:
public class user1
{
public string id { get; set; }
public comment[] comments { get; set; }
}
public class comment
{
public int status { get; set; }
}
then the query should be something like:
var query =
collection.asqueryable<user1>().selectmany(user => user.comments.where(com=>com.status == 1));
Source: stackoverflow.com
Related Query
- Mongo Driver Linq Query throws Exception
- How to query nested list in Mongo C# 2.2 driver with Linq?
- Avoid extra loop and could not find implementation of query pattern for source type int Select not found
- Mongo c# Driver Query (Select subfields)
- Querying Mongo when a document have one to many relationship in a single well structed query using mongo C# driver
- How to Select top (5) contributors group by Business type code in c# linq query
- How to write aggregate query in LINQ reusing part of the select code
- How can I convert this console mongodb query to a C# mongo driver v2 one?
- Code first one to one select query
- LINQ query to select top five
- Linq code to select one item
- How to Select Min and Max date values in Linq Query
- Can I select multiple objects in a Linq query
- Linq UNION query to select two elements
- How to write linq query to match SQL like select top 100 * from tab?
- Could not find an implementation of the query pattern for source type 'System.Data.Entity.DbSet'
- LINQ query to perform a projection, skipping or wrapping exceptions where source throws on IEnumerable.GetNext()
- LINQ select query with Anonymous type and user Defined type
- MongoDb c# driver LINQ vs Native query
- A query body must end with a select clause or a group clause why is here an error?
- simple select query in linq
- Default value for linq select item if query didn't return anything
- Dynamically build select list from linq to entities query
- linq distinct and select new query
- Using Function in Select Clause of Entity Framework Query
- Linq query to select top records
- LINQ Query - How to map a resultset into another object using Select
- Is there any way to create a LINQ query as a variable without having the data source (yet)?
- Select records count from multiple tables in a single query
- Nested LINQ query to select 'previous' value in a list
More Query from same tag
- How to Concat String in LINQ SQL WHERE clause?
- C# XML LINQ Syntax on Attributes
- FIND items in list using lambda expression
- need to convert sql join query with count into linq and pass it to view
- linq sum in vb.net
- Entity Framework and LINQ together Batch Update
- Linq to Sql Group By without count
- LINQ: Finding an item in a List which contains List of items
- Why is IQueryable twice as fast than IEnumerable when using Linq To Objects
- C# Linq exact part of collection
- C# ?? operator and ora-12704: character set mismatch
- How to display Company in header in asp.net mvc 3
- Covariance/Contravariance with a linq expression
- Linq to Entities Filtering an Entity Dynamic/Strongly Typed
- How to iterate only distinct string values by custom substring equality
- Nhibernate 3.0 IQueryOver group by and fetch one entire record in each group which satisfy the condition
- Convert Linq Query Result to Dictionary
- No generic method 'ThenBy' on type 'System.Linq.Queryable'
- Is it necessary use thread-safe methods when i use AsParallel?
- EntitySet vs Table query performance in LINQ2SQL
- Linq Query Optimization
- Need help in solving SQL
- Does not save into correct database
- The entity or complex type 'xyz' cannot be constructed in a LINQ to Entities query
- C# Abstract Generic Method
- Compare two DirectoryInfo and remove from A where B Exists. LINQ?
- Remove List Elements that appear more than Once In Place
- Search a part of a List<> based on the indext of a pattern match
- Problem with a Linq to Entity query that contains a passed list of entities
- how to use an expression in a select clause