Saturday, 15 February 2014

c# - Mapping a private member and populate it back with a method in MongoDB -



c# - Mapping a private member and populate it back with a method in MongoDB -

with mongodb c# drivers can map private fellow member this

cm.mapfield("_sessiontimes").setelementname("sessiontimes");

and populates sessiontimes in mongodb.

this private member, isn't backing field of public property.

is there way populate field while getting entity form mongodb?

my class has addsessiontime method, ideally utilize method populate private field while mongodb drivers deserializing entity.

by way type of _sessiontimes

idictionary<dayofweek, sessiontime>

sessiontime simple class:

public class sessiontime { public timespan start { get; set; } public timespan end { get; set; } }

and addsessiontime method in class:

public void addsessiontime (dayofweek dayofweek, sessiontime sessiontime) { if (_sessiontimes.containskey(dayofweek)) { _sessiontimes[dayofweek] = sessiontime; } else { _sessiontimes.add(dayofweek, sessiontime); } }

thanks.

c# mongodb mongodb-csharp

No comments:

Post a Comment