Reputation: 595
I am trying to get some results from MongoDB
using C# driver
(Latest driver Version 2.0.1.27).
This is how I call the mongo :
public static async Task < List < MomLogModel >> MomLogAr(MomLogArModel arama) {
var asd = Builders < MomLogModel > .Filter.Where(a => a.SipID == arama.SipID);
asd = asd & Builders < MomLogModel > .Filter.Where(a => a._id == arama._id);
var donucek = await mongoContex.MomLog.Find(asd).ToListAsync().ConfigureAwait(false);
}
This is the class of MomLogModel :
public class MomLogModel {
[BsonRepresentation(BsonType.ObjectId)]
public string _id {
get;
set;
}
[BsonElement("g")]
public BsonDocument gelen {
get;
set;
}
[BsonElement("t")]
public DateTime YaratTarih {
get {
return DateTime.Now;
}
set {
YaratilisTarih = value;
}
}
[BsonElement("m")]
public string MesajKod {
get;
set;
}
[BsonElement("re")]
public bool Rar {
get;
set;
}
[BsonElement("kz")]
public double KaZa {
get;
set;
}
[BsonElement("si")]
public int SipID {
get;
set;
}
}
When I run this I get the following error :
Method not found: 'Boolean MongoDB.Bson.Serialization.IBsonArraySerializer.TryGetItemSerializationInfo(MongoDB.Bson.Serialization.BsonSerializationInfo ByRef)'.
I have tried removing the BsonRepresentation
from model but it didn't solve the issue.
Also tried changing it but cannot figure out what is causing the problem at all.
Upvotes: 1
Views: 3999
Reputation: 595
It appears that , in a project which i was adding this projects dll , I had MongoDB.Bson and its version was an older one.
So having 2 difference versions referencing was causing the problem as @CraigWilson suggested.
Updating the reference resolved the issue.
Upvotes: 7