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();

Related Query