score:0
Accepted answer
the problem was indeed within the method getcollection<>() once i replaced it with the following code, it worked just fine:
public mongocollection<t> getcollection<t>(string name = null)
{
string collectionname = name;
if (collectionname == null)
collectionname = typeof(t).name;
if (database.collectionexists(collectionname) == false)
database.createcollection(collectionname);
return database.getcollection<t>(collectionname);
}
score:0
you can also change it to something like
var usr = users.asqueryable().where(u => u.username.equals(username)).firstordefault();
Source: stackoverflow.com
Related Query
- Either an issue with my linq statement or with my GetCollection<T>()
- Linq Join With Include Statement
- Linq Query with a Where clause in an Include statement
- List to Dictionary with incremental keys in one line LINQ statement
- How to introduce Let keyword inside Linq statement with Group by
- Unwieldy LINQ statement with multiple search criteria
- LINQ groupby statement with key
- Issue with dynamic LINQ queries containing brackets
- NHibernate 3 LINQ inner join issue with three jumps: NotSupportedException
- LINQ Source Code Available
- Use == operator with generic type in a Where Linq statement
- How to construct a having statement in linq with a max value?
- Issues with LINQ statement with defining an element of a collection
- Linq with where clause in many-to-many EF Code First object
- EntityFramework 6.1.1 with Linq Performance issue
- LINQ to SQL: Issue with concurrency
- LINQ Query with both CASE statement and SUM function
- A linq statement with multiple group by columns not allowing a thenby
- I'm trying to simplify with linq a statement that takes 2 lists of numbers and subtracts the first one from the second one
- Issue With LINQ and Reference List
- how to deal with exception in LINQ Select statement
- Programmatically building a query with LINQ statement with entity framework
- Linq statement with two where clauses
- Split list into two lists with single LINQ statement
- Entity Framework - LINQ statement with WHERE clause based on NULLABLE parameter
- C# - Linq optimize code with List and Where clause
- Select method missing from intellisense with Linq statement
- select from linq statement with await
- Linq statement with mutiple OrderBy clauses not working
- LINQ Join statement with possible NULL id?
More Query from same tag
- How to write this in Linq? group and get max
- Using .Where() on a List
- Linq intersect a child list of integers against a list of integers
- Bind Two List With Column Match
- Linq on string array
- SQL to LINQ - Case Statement
- materialization and performance for aggregation/concatenation of IEnumerable properties
- LINQ to SQL doesn't exist in my visual studio 2012
- Solve casting error in lambda
- LINQ Expression not evaluating correctly
- Using the Iqueryable list result from one query as the parameter for another?
- Entity Framework : filter based on last level child entity
- fancy way to load contents of a CSV file into a dictionary<string,string> in C#
- LINQ get global index
- C# List Join List And Filter From Another List
- Join LINQ-query with predicate
- LINQ on IList of objects
- cannot implicitly convert type int to model type
- Optimize or ditch LINQ query?
- ArrayList Problem in LINQ
- LINQ Select Multiple Elements from a List<object[]>
- Cannot convert from Expression< Func< Entity, bool> > to Func< Entity, bool>
- IList does not contain a definition <linq function>
- How can I populate a list of objects from another list using LINQ?
- Another Linq translation question
- Entity Framework Code First override onModelCreating() for TPT Inheritance Screwing Up Identity User and Role Models
- When are collections enumerated (IEnumerable)
- Nested Using statements affects performance
- Braces in ComboBox
- Using SQL "In" instead of "Like" using %wildcards% in Linq