Coder Social home page Coder Social logo

atheken / norm Goto Github PK

View Code? Open in Web Editor NEW
398.0 398.0 82.0 16.33 MB

NoRM is a MongoDB driver for .Net designed to provide access to strongly/statically-typed documents and collections.

License: BSD 3-Clause "New" or "Revised" License

ASP 2.29% JavaScript 8.39% C# 89.32%

norm's People

Contributors

amorano avatar averyj avatar candland avatar darrenkopp avatar dennyferra avatar emmekappa avatar ereichert avatar hdeshev avatar hyrmn avatar jasona avatar kenegozi avatar ooswald avatar pwigle avatar saleemjavid avatar schotime avatar stuartharris avatar subsonic avatar troygoode avatar tylerbrinks avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

norm's Issues

Stomping properties.

Updates should only alter properties that are defined on the document, and should leave other properties untouched when updating.

Invalid type when using generics and MongoDiscriminated

When using the attribute [MongoDiscriminated] on a generic class, the type string return by ReflectionHelper.GetTypeDiscriminator() is truncated and not valid which lead to an exception when using it in Type.GetType().

With the following code :

class Program
{
    [Norm.MongoDiscriminated]
    class Error<T>
    { }

    static void Main(string[] args)
    {
        var helper = new Norm.BSON.ReflectionHelper(typeof(Error<int>));
        Console.WriteLine(helper.GetTypeDiscriminator());
    }
}

I get the following type :
test.norm.Program+Error`1[[System.Int32, mscorlib

When the valid type would have been :
test.norm.Program+Error`1[[System.Int32, mscorlib]], test.norm

Any plans to allow Predicate and Expressions in the query language?

Any plans to allow something like this?

var linq = new List<Predicate> { c => c.OwnerId== criteria.OwnerId, };

        if (criteria.Status.HasValue)
            linq.Add(c => c.StatusCd == criteria.Status.Value);
        if (!string.IsNullOrEmpty(criteria.Source))
            linq.Add(c => c.Source == criteria.Source);
        Expression<Func<Client, bool>> where = p => linq.All(pred => pred(p));
        return Session.All<Client>().Where(where).OrderByDescending(c => c.ModifiedDt).ToList();

Support for custom type mappers to/from BSON type

Offen I need to store document with not supported types (TimeSpan,CultureInfo,other)
It will be nice to have ability to set type mappers to/from BSON type

for example:
TimeSpan -> BSON = TimeSpan.Ticks
CultureInfo -> BSON = CultureInfo.GetWebName()

Serializing custom types (proposal)

I'm using NoRM from a month ago and tried to implement everything I needed on my own classes instead of customizing the library (I consider modifying third-party code is a bad practice).

Now I've found I need to use a custom data type that should serialize to a primitive type. E.g., i want a "UnixTime" class that stores to the DB as a long, e.g.:

class MiClass {
public ObjectId _id { get; set; }
public UnixTime time { get; set; }
}

In the database, I don't want to store a "time: { seconds: 0 }", instead I want "time: 0".

To do that I should modify the BSONSerializer and BSONDeserializer classes, or to create an ignored property to work with UnixTime, then a property of type long with the long value for the UnixTime.

I think should be cool if NoRM supports at least one of those:

  • Classes implementing TypeConverter uses it to serialize and deserialize (I think is the best choice).
  • Classes with ISerializable serializes using Parse() and ToString().

Problematic 'Save' for entities with ID of types int? and long?

I think there is a problem with the (MongoCollectionGeneric) Save(T entity).
nullable int and longs are directed to Insert flow instead of update.

The expression:

       if (id == null && 
            (typeof(ObjectId).IsAssignableFrom(idProperty.Type)) ||
            (typeof(long?).IsAssignableFrom(idProperty.Type)) ||
            (typeof(int?).IsAssignableFrom(idProperty.Type)) )

is problematic since Long? and int? are always entering - whether if null or not.
Solution: () should be added over all || cases.

NoRM does not work with the "mongos" process (production set up)

I have the following set up. 4 shards, 3 config servers, and 1 router server. NoRM does not function correctly in this situation which is a real world like set up. In my testing the NoRM driver connects through the "mongos" process instead of connecting to the "mongod" process. If I run the unit test against a single "mongod" database everything works great. If i run the unit test against the production set up, tons of tests fail. While the library is awesome, it really came as a surprise that it seems that it has never been tested in a production like set up. I really hope this is something that is fixed soon.

Count() method coming from IQueryable interface throws assertions on server

When i call Count() method from IQueryable interface without query parameters, the server throws the following assertion:
server log with(-vvvv specified):
Thu Jul 01 20:46:04 run command databasetest.$cmd { query: { count: "Product", query: {} } }
Thu Jul 01 20:46:04 query galeriadoamor.com.$cmd ntoreturn:1 0ms
Thu Jul 01 20:46:04 Assertion failure toSend.data util\message.cpp 380
Thu Jul 01 20:46:04 AssertionException in connThread, closing client connection

The code i tested is:

long count = db.GetCollection().FindAll().Count();
The class description is pasted below:

public class Product
{
[MongoIdentifier]
public int? ID { get; set; }
public List AvailableDescriptions { get; set; }

    public double Weight { get; set; }

    public string InternalName { get; set; }
}
public class ProductDescription
{
    public string Language { get; set; }
    public string Description { get; set; }
    public string CompleteDescription { get; set; }
    public double Price { get; set; }
    public List<ProductFeature> Features { get; set; }

    public double AdditionalWeight { get; set; }
    public double PackageWeight { get; set; }

    public ProductStatus ProductStatus { get; set; }
}
public class ProductFeature
{
    public string FeatureName { get; set; }
    public List<FeatureOption> Options { get; set; }

}
public class FeatureOption
{
    public string Description { get; set; }
    public decimal AdditionalPrice { get; set; }
    public string Type { get; set; }
}

Error when deserializing document when object does not contains this property

When a field is added to the document and the object does not have this property, first, an OutOfmemoryException is thrown, then various errors occurs in other object deserialization that is not related with the first.
The workaround is remove the field from mongodb, then reset the pooled connections.
How to reproduce:

  1. Save an object with some properties;
  2. Retrieve the set of objects;
  3. Add some field using mongodb using $set: {SomeField: someValue}
  4. Retrieve the same set of objects. An error saying that the deserialization was failed because "SomeField" does not exist.
  5. Try to retrieve a set of objects from other collection. An OutOfMemoryException is thrown.

Cannot serialize Expando objects as properties of Expando objects

All properties of an Expando is serialized using SerializeMember. This in turn does not call WriteDocument, but only WriteObject, which means any inner Expando objects are serialized as "real" objects. This again means deserialization fails.

This is not an issue for me, and apparently not any one else, so maybe it's not that important?

Cannot use IQueryable.Where with class Id property

If I have a document class with a composite Id (i.e. using a custom class) and I access the Id property in the IQueryable.Where method for the associated collection, the property is not aliased correctly. Example:

class CustomerId { public string Type { get; set; } public int SeqNum { get; set; } }

class Customer
{
public CustomerId Id { get; set;}
public string Name { get; set;}
}

var x = database.GetCollection().AsQueryable().Where(c => c.Id.Type == "Premium");

Incorrect exception whe using non-static Regex.IsMatch

When I try to use an instance of Regex in the predicate of my Linq expression, I get ArgumentOutOfRangeException. Whereas there should be the following exception:

throw new NotSupportedException(string.Format("Only the static Regex.IsMatch is supported.", m.Method.Name));

BSON serializer too slow

Using Newtonsoft Json library to write a BSON byte array in SpeedTest is 10x to 15x faster than the current BSON serializer (with a gotcha: Newtonsoft library serializes Guids as string, but it's easy to make a custom serializer for it).

Potential bug in MongoConfigurationMap.cs

During my work with the configuration code, I found this piece in MongoConfigurationMap.cs:

public string GetPropertyAlias(Type type, string propertyName)
{
 var map = MongoTypeConfiguration.PropertyMaps;
 var retval = propertyName;//default to the original.

 if (IsIdPropertyForType(type, propertyName) && !IsDbReference(type))
 {
  retval = "_id";
 }
 else if (map.ContainsKey(type))
 {
  foreach (var m in map.Keys)
  {
  // Might find a property with same name, but in other type???
   if (map[m].ContainsKey(propertyName))
   {
    retval = map[m][propertyName].Alias;
    break;
   }
  }
 }
 return retval;
}

I believe the highlighted "foreach" section is wrong. I would expect:

public string GetPropertyAlias(Type type, string propertyName)
{
 var map = MongoTypeConfiguration.PropertyMaps;
 var retval = propertyName;//default to the original.

 if (IsIdPropertyForType(type, propertyName) && !IsDbReference(type))
 {
  retval = "_id";
 }
 else if (map.ContainsKey(type))
 {
  var properties = map[type];
  if (properties.ContainsKey(propertyName))
  {
   retval = properties[propertyName].Alias;
   break;
  }
 }
 return retval;
}

Add Support for GridFS

Apart from unlocking GridFS functionality of MongoDB for C#, having GridFS support works well as a workaround for BSON's 4MB limit

Connection string exception

I get the exception: The connection string passed does not appear to be a valid Uri, it should be of the form: 'mongodb[rs]://[user:password]@host:[port]/[replicaSetName]/dbname?[options]' where the parts in brackets are optional.

The problem is that my connection string contains a #

NORM cannot handle lambda expressions where the type is an interface type

NORM cannot handle expressions where the type is an interface type.

For example, in a generic class that has an interface constraint on the type, when I access a property of T, e.g. ".UniqueIdentifier" NORM cannot handle the expression and an Exception is thrown (relating to its inability to case a UnaryExpression to a ParameterExpression).

            var existing = db.GetCollection<T>().AsQueryable().SingleOrDefault(x => x.UniqueIdentifier == uid);

In this expression 'x.UniqueIdentifier' has a NodeType=Convert wrapped around it to perform the cast to the interface.

It's actually a fairly simple fix: In MongoQueryTranslator.cs, about line 407 there is an if statement in ...

    private static ParameterExpression GetParameterExpression(Expression expression)

Adding the following clause to the if statement solves the problem:

    ...
            else if (parentExpression.NodeType == ExpressionType.Convert)
            {
                parentExpression = ((UnaryExpression)parentExpression).Operand;
                expressionRoot = parentExpression is ParameterExpression;
            }

Save GridFile problem

when i upload a file, i found the GridFS didn't save the file content in CachedChunks. See the code i modify, i don't kown how the MongoDB save the file in chunk, is it need add FileChunk into CachedChunks?

in the GridFile.cs,

 do
            {
                var binary = value.Skip(cursor)
                    .Take(this.ChunkSize).ToArray();

                takeCount = binary.Length;
                cursor += takeCount;

                if (takeCount > 0)
                {
                    var c = new FileChunk();
                    c.ChunkNumber = chunkNumber;
                    c.FileID = this.Id;
                    c.BinaryData = binary;

               //   this.CachedChunks.Add(c);    <-- here i add this line, it works.

                    chunkNumber++;
                }

            } while (takeCount > 0);

The public MapReduceResult<T> class isn't flexible enough to handle all MapReduce operations

Currently the class reads thus:-

/// <summary>
/// The map reduce result.
/// </summary>
/// <typeparam retval="T">Type to map and reduce</typeparam>
public class MapReduceResult<T>
{
    /// <summary>
    /// Gets or sets Id.
    /// </summary>
    public int Id { get; set; }

    /// <summary>
    /// Gets or sets Value.
    /// </summary>
    public T Value { get; set; }
}

If instead it was like this it could handle all MapReduce results:

/// <summary>
/// This is a useful type for dealing with MapReduce results.  
/// It takes two type parameters, one for the key and one for the value.
/// The simplest possible result would use type parameters ObjectId and int
/// </summary>
public class MapReduceResult2<Tid, Tvalue>
{
    public Tid _id { get; set; }
    public Tvalue value { get; set; }

    public override string ToString()
    {
        return string.Format("{0} {1}", _id, value);
    }
}

Suggest either replacing it with the more flexible version or making it internal so it's not exposing a class that has no use outside NORM.

Concurrency Support

We don't currently deal with concurrency at all in the driver, this should be dealt with.

Authentication issue

Hello, i am having an issue when trying to authenticate with a database. I have started the mongod server with --auth, i have set up the user for the admin database and the user for my database.

Now, i am trying to connect with:

_mongo= new Mongo("dbname", "user:pass@localhost", "27017", "");

Everything works normally when authenticating from the command line. However, when authenticating with NoRM, i get two alternating exceptions:

db assertion failure

[MongoException: db assertion failure]
   Norm.BSON.BsonDeserializer.HandleError(String message) +34
   Norm.BSON.BsonDeserializer.ReadObject(Type type) +212
   Norm.BSON.BsonDeserializer.DeserializeValue(Type type, BSONTypes storedType, Object container) +706
   Norm.BSON.BsonDeserializer.Read(Int32 length) +74
   Norm.BSON.BsonDeserializer.Deserialize(BinaryReader stream, Int32 length) +72
   Norm.BSON.BsonDeserializer.Deserialize(Int32 length, BinaryReader reader, IDictionary`2& outProps) +47
   Norm.Protocol.Messages.ReplyMessage`1..ctor(IConnection connection, String fullyQualifiedCollestionName, BinaryReader reply, MongoOp originalOperation, Int32 limit) +328
   Norm.Protocol.Messages.QueryMessage`2.Execute() +543
   Norm.ConnectionProvider.Authenticate(IConnection connection) +370
   Norm.ConnectionProvider.CreateNewConnection() +106
   Norm.PooledConnectionProvider.Open(String options) +256
   Norm.Mongo.ServerConnection() +23
   Norm.Mongo..ctor(String db, String server, String port, String options) +104

and

unauthorized for db [dbname] lock type: -1

[MongoException: unauthorized for db [dbname] lock type: -1
]
   Norm.BSON.BsonDeserializer.HandleError(String message) +34
   Norm.BSON.BsonDeserializer.ReadObject(Type type) +212
   Norm.BSON.BsonDeserializer.DeserializeValue(Type type, BSONTypes storedType, Object container) +706
   Norm.BSON.BsonDeserializer.Read(Int32 length) +74
   Norm.BSON.BsonDeserializer.Deserialize(BinaryReader stream, Int32 length) +72
   Norm.BSON.BsonDeserializer.Deserialize(Int32 length, BinaryReader reader, IDictionary`2& outProps) +47
   Norm.Protocol.Messages.ReplyMessage`1..ctor(IConnection connection, String fullyQualifiedCollestionName, BinaryReader reply, MongoOp originalOperation, Int32 limit) +328
   Norm.Protocol.Messages.QueryMessage`2.Execute() +543
   Norm.d__0.MoveNext() +103
   System.Linq.Enumerable.FirstOrDefault(IEnumerable`1 source) +215
   Norm.Linq.MongoQueryProvider.ExecuteQuery(Expression expression) +1469
   Norm.Linq.MongoQueryProvider.System.Linq.IQueryProvider.Execute(Expression expression) +52
   System.Linq.Queryable.FirstOrDefault(IQueryable`1 source) +269

Am i doing something wrong here or is it a bug with the NoRM driver?

Does norm support complex group by?

Does norm support complex group by in linq, such as

db.GetCollection<Action>().AsQueryable().Where(...)
.GroupBy(o => (o.UtcActionTime + timeOffset).Date).Select(...)

CultureInfo support

I was trying to store an instance of CultureInfo. The BSON serializer crashed with a stack overflow due to the fact that CultureInfo has a Parent property which refers to itself, thereby making a circular reference.

A CultureInfo can be stored as a simple string like "en-US".

There must be a ton of simple value objects like this that cannot immediately be serialized even though they have a simple string representation. I suggest some kind of plugin structure where one can add "tostring" serializers (or more generic serializers) for certain objects. The class mapping is not really good enough here.

Non serializable types

Due to a caching system that I've implemented on top of Norm, I need to serialize Mongo records using system serializers. Unfortunately, I've had to manually modify the ObjectId type (the one I use right now) to add the [Serializable] attribute and allow, then, the record to be serialized.

I think that in-record data types should be serializable by default.

GridFile and custom Id

If following code is used to create GridFile resulting file will be invalid.

var file = new GridFile()
{
Content = content,
Id = Norm.ObjectId.NewObjectId(),
UploadDate = DateTime.Now,
FileName = filename,
ContentType = contentType
};
mongoDb.Files().Save(file);

Reason is that when Content is set autogenerated Id is used. Then Id is changed which result that file and chunks are not related anymore.... Id change should be forbidden after content is set, or all chunks should be updated to use new Id.

It's not a big issue, but it took me a few hours and forced me to debug norm code :)
BTW, great lib ...

Replica Set Connection String should allow several hosts of the replica set to be specified

It is entirely possible that more than one host in a ReplicaSet may be down at any point (for maintenance, server crash, etc.). The Connection string should follow the form used in the 10gen driver (http://www.mongodb.org/display/DOCS/CSharp+Driver+Tutorial#CSharpDriverTutorial-Connectionstrings) of allowing multiple hostnames to be specified (separated by commas) which will each be queried until one responds. This allows the first server to be down, but the second one/third one to work.

Thanks.

ArgumentOutOfRange Exception using AsQueryable().ToList()

I'm trying to do the following:

            var collection = m.GetCollection<Post>()
                .AsQueryable().ToList();

However, this throws an ArgumentOutOfRangeException:
Non-negative number required.
Parameter name: count

Am I doing something wrong...?

Stack Trace:

at Norm.BSON.BsonDeserializer.Deserialize[T](BinaryReader stream, Int32 length) in C:\Users\alexb\Downloads\atheken-NoRM-v0.9.8-4-gd8faa81\atheken-NoRM-d8faa81\NoRM\BSON\BsonDeserializer.cs:line 102
at Norm.BSON.BsonDeserializer.Deserialize[T](Int32 length, BinaryReader reader, IDictionary2& outProps) in C:\Users\alexb\Downloads\atheken-NoRM-v0.9.8-4-gd8faa81\atheken-NoRM-d8faa81\NoRM\BSON\BsonDeserializer.cs:line 76 at Norm.Protocol.Messages.ReplyMessage1..ctor(IConnection connection, String fullyQualifiedCollestionName, BinaryReader reply, MongoOp originalOperation, Int32 limit) in C:\Users\alexb\Downloads\atheken-NoRM-v0.9.8-4-gd8faa81\atheken-NoRM-d8faa81\NoRM\Protocol\Messages\ReplyMessage.cs:line 60
at Norm.Protocol.Messages.QueryMessage2.Execute() in C:\Users\alexb\Downloads\atheken-NoRM-v0.9.8-4-gd8faa81\atheken-NoRM-d8faa81\NoRM\Protocol\Messages\QueryMessageGeneric.cs:line 119 at Norm.MongoQueryExecutor3.d__0.MoveNext() in C:\Users\alexb\Downloads\atheken-NoRM-v0.9.8-4-gd8faa81\atheken-NoRM-d8faa81\NoRM\MongoQueryExecutor.cs:line 74
at System.Collections.Generic.List1..ctor(IEnumerable1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
at MongoTest.Program.justGetTitles() in C:\Users\alexb\Desktop\New folder\MongoTest\MongoTest\Program.cs:line 112
at MongoTest.Program.Main(String[] args) in C:\Users\alexb\Desktop\New folder\MongoTest\MongoTest\Program.cs:line 27
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()

NoRM returns wrong number of results

When performing the following query which i know real result count I get fewer results than expected.

string[] ids = {"", "", ... };
collection.Find( new { _id = Q.in( ids ));

if my list of ids was 8222, i might only get back 789 records. To me this seems to be a big bug. I had to resort to retrieving records in batches of 100 at a time.

Exception using complex where clause

I get the following exception when trying to do a rather complex query:

Unable to cast object of type 'System.Linq.Expressions.BinaryExpression' 
to type 'System.Linq.Expressions.MemberExpression'.

Query: var result = 
  Context.Query<Subscription>().
    Where(s => s.LastReportTicks + s.Interval * TicksPerDay < NowTicks).
    OrderBy(s => s.LastReportTicks + s.Interval * TicksPerDay);

at Norm.Linq.MongoQueryTranslator.HandleSort(Expression exp, OrderBy orderby) 
in MongoQueryTranslator.cs

The cast to (MemberExpression) assumes there's only a simple member access... I fiddled around a bit, but I was unable to fix this so far.

MapReduce with GUID in Map function

Hi,

Seems that there is a bug with using Guid in the map function when doing MapReduce.

If I try to do this.query.Where(c => c.RessourceIdentifier = myGuid).Average(c => c.Value) I get no result if RessourceIdentifier is a Guid.
It works if RessourceIdentifier is a numeric.
Maybe it's because a Guid is stored as binary data in mongodb and in the map function you try to match the Guid as a string.

public class TestGuidIssue
{
public Guid RessourceIdentifier { get; set; }
public int Value { get; set; }
}

Multi-threading issue

Norm.ConnectionProviderFactory is not multithread safe. (but pretends to be :) It has a double lock pattern that will not work since _cachedBuilders's TryGetValue() is not an atomic operation. i.e. TryGetValue() (outside the lock) might be running at the same time as Add() on the same dictionary. A simple solution is copy on write.

Json.Net support

Json.Net is powerfull and customizable product. Can you add support for Json.Net as pluggable serializer?

Linq Query with byte[] Constant

The following method will crash with an NotSupportedException("The constant for 'byte[]' is not supported") thrown at MongoQueryTranslator.cs:699. Any chance to get this to work or is this a limitation of MongoDb or BSON?

public Guid? GetUserIdByUsernamePassword(string Username, byte[] Password)
{
using (var db = ServiceLocator.Get())
{
var users = db.GetCollection();
var user = users.AsQueryable().Where(x => x.Username == Username && x.Password == Password).FirstOrDefault();

    if (user == null)
        return null;

    return user.Id;
}

}

Column aliases

Given a class to be persisted using Norm that in its static constructor declares the column aliases as shown in your examples in http://wiki.github.com/atheken/NoRM/configuration, when I save the class everything goes ok, fields are persisted to the database using the aliases. Unfortunately, when I load the class from the database, an exception throws because there is no property in the class named as the alias. E.g., if I have a column named "foo" and I set its alias to "bar", when I save the object, the column is named "bar" in the database. But when I load the object from the database (i.e., using Find()), an exception says that there is no property named "bar" in the object.

Gem for NoRM

Andrew,

I added a gem for NoRM 0.9.7 to rubygems.org. If you're interested in keeping it updated let me know the email address associated with your rubygems.org account and I can add you as an owner. I'm starting to use nu (The gem tool for .NET: http://bit.ly/dvd7gJ) and wanted to make this available via that mechanism.

Here is the rake task I used to generate the gem if your interested: http://gist.github.com/504594

Thanks!

m

Sign NoRM

NoRM can't be referenced from a strongly named assembly right now since it doesn't have a strong name key and is not signed. Could you please create a key so that it can be signed.

Can NoRM handle Contains with LINQ?

Given the class

    public class Note {
    public Note() {
        Tags = new List<string>();
    }

    public ObjectId Id { get; set; }
    public string Title { get; set; }
    public string Body { get; set; }
    public List<string> Tags { get; set; }
}

I am getting an exception when I run the following LINQ statement

return mongo.GetCollection<Note>().AsQueryable().Where(x => x.Tags.Contains(_tag));

[ArgumentNullException: Value cannot be null.
Parameter name: source]
   System.Linq.Enumerable.Cast(IEnumerable source) +730580
   Norm.Linq.MongoQueryTranslator.HandleContains(MethodCallExpression m) in C:\Projects\NoRM\NoRM\Linq\MongoQueryTranslator.cs:1041
   Norm.Linq.MongoQueryTranslator.VisitMethodCall(MethodCallExpression m) in C:\Projects\NoRM\NoRM\Linq\MongoQueryTranslator.cs:847
   Norm.Linq.ExpressionVisitor.Visit(Expression exp) in C:\Projects\NoRM\NoRM\Linq\ExpressionVisitor.cs:70
   Norm.Linq.MongoQueryTranslator.VisitPredicate(Expression expr, Boolean IsNotOperator) in C:\Projects\NoRM\NoRM\Linq\MongoQueryTranslator.cs:378
   Norm.Linq.MongoQueryTranslator.HandleWhere(Expression exp) in C:\Projects\NoRM\NoRM\Linq\MongoQueryTranslator.cs:1035
   Norm.Linq.MongoQueryTranslator.TranslateToWhere(MethodCallExpression exp) in C:\Projects\NoRM\NoRM\Linq\MongoQueryTranslator.cs:1022
   Norm.Linq.MongoQueryTranslator.HandleMethodCall(MethodCallExpression m) in C:\Projects\NoRM\NoRM\Linq\MongoQueryTranslator.cs:1154
   Norm.Linq.MongoQueryTranslator.VisitMethodCall(MethodCallExpression m) in C:\Projects\NoRM\NoRM\Linq\MongoQueryTranslator.cs:841
   Norm.Linq.ExpressionVisitor.Visit(Expression exp) in C:\Projects\NoRM\NoRM\Linq\ExpressionVisitor.cs:70
   Norm.Linq.MongoQueryTranslator.Translate(Expression exp, Boolean useScopedQualifier) in C:\Projects\NoRM\NoRM\Linq\MongoQueryTranslator.cs:101
   Norm.Linq.MongoQueryProvider.ExecuteQuery(Expression expression) in C:\Projects\NoRM\NoRM\Linq\MongoQueryProvider.cs:103
   Norm.Linq.MongoQuery`1.GetEnumerator() in C:\Projects\NoRM\NoRM\Linq\MongoQuery.cs:123
   System.Linq.Enumerable.Count(IEnumerable`1 source) +177

Getting "Connection timeout"

Any ideas why this exception is thrown every ~5 minutes?

[MongoException: Connection timeout trying to get connection from connection pool]
Norm.PooledConnectionProvider.Open(String options) in D:\Coding\DotNet\OS\NoRM\NoRM\Connections\PooledConnectionProvider.cs:62
Norm.Mongo.ServerConnection() in D:\Coding\DotNet\OS\NoRM\NoRM\Mongo.cs:189
Norm.Mongo..ctor(String db, String server, String port, String options) in D:\Coding\DotNet\OS\NoRM\NoRM\Mongo.cs:90
Norm.Mongo..ctor(String db) in D:\Coding\DotNet\OS\NoRM\NoRM\Mongo.cs:44

Add support for server status

db.$cmd.findOne({serverStatus:1})
{
"uptime" : 275387,
"globalLock" : {
"totalTime" : 275386956000,
"lockTime" : 1300000,
"ratio" : 0.000004720630268341395
},
"mem" : {
"resident" : 2,
"virtual" : 887,
"supported" : true,
"mapped" : 848
},
"ok" : 1
}

(just putting this in so I don't forget)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.