[CSHARP-2292] FilterDefinitionBuilder error {document}.FieldName is not supported Created: 05/Jun/18 Updated: 27/Oct/23 Resolved: 15/Feb/22 |
|
| Status: | Closed |
| Project: | C# Driver |
| Component/s: | Linq |
| Affects Version/s: | 3.0.0 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Minor - P4 |
| Reporter: | AMOUZIGH Driss | Assignee: | James Kovacs |
| Resolution: | Works as Designed | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Epic Link: | CSHARP-3615 |
| Description |
|
Hello, I'm using trying to do an upset using this code: List<UpdateOneModel<IChannelItem>> requests = new List<UpdateOneModel<IChannelItem>>(items.Count);
Classe IChannelItem: public interface IChannelItem : IDataItem { int Id \{ get; set; }string Identifier { get; }string Type { get; } string Value { get; set; }string Quality { get; set; } string Timestamp_utc { get; set; }string Timestamp_local { get; } DateTime DateAction { get; } string Origin { get; } bool added { get; set; } string JSon { get; }}
I'm getting this error:
Regards, Driss |
| Comments |
| Comment by James Kovacs [ 15/Feb/22 ] | |||
|
The driver's serialization code requires setters to modify properties. This includes deserializing instances of a class. Consider the following property definition:
The compiler generates an auto-prop getter that returns the value of the underlying compiler-generated field. There is no compiler-generated setter for setting that field. The driver would have to guess the name of the backing field based on compiler naming conventions. We choose not to do that and instead rely on compiler-generated setters. These setters can be marked as private or init if you do not want users of your class to modify them.
If you modify your class definition to include private set or init for those properties, the class can be serialized and deserialized successfully. |