我有这样的结构:如何使用10gen c#驱动程序更新内部属性?
public class User
{
public ObjectId Id { get; set; }
public Location Location { get; set; }
public DateTime LastAround {get;set;}
}
public class Location
{
public double Latitude { get; set; }
public double Longitude { get; set; }
}
我已经尝试了一些东西,但我想更新用户的位置,当他们最后四周。
尝试这样:
userHelper.Collection.Update(
Query.EQ("_id", userId),
Update.SetWrapped<Location>("Location", new Location { Latitude = latitude, Longitude = longitude }).Set("LastAround", DateTime.UtcNow));
这:
userHelper.Collection.Update(
Query.EQ("_id", userId),
Update.Set("Location.Latitude", latitude)
.Set("Location.Longitude", longitude)
.Set("LastAround", DateTime.UtcNow));
毫无效果......我该怎么办呢?
更新4/17:
userHelper.Collection.Update(
Query.EQ("_id", new ObjectId(userId)),
Update
.SetWrapped<Location>("Location", new Location { Longitude = longitude, Latitude = latitude })
.Set("LastAround", DateTime.UtcNow)
);
液化天然气和纬度值的订单似乎对他们做查询时是非常重要的。我正在做一个geonear查询并得到一个奇怪的越界错误。如果您按照错误的顺序更新,它会先放入拉丁文,然后出现错误。
奇怪,我不知道为什么我的工作不正常。我已经了解到,尽管geo查询lat和lng需要先切换lng。 – rball 2012-04-17 21:16:50