Comments (4)
@danludwig yes this is a bug, i should look into it. but for now you can use [JsonIgnore]
json.net attribute for ignoring members
just be aware you should use embeded json.net
[ArangoDB.Client.Common.Newtonsoft.Json.JsonIgnore]
and you dont need JsonIgnore
on overrided members
public abstract class ContactInfo
{
public SomeEnum SomeEnumValue { get; set; }
[JsonIgnore]
public abstract string ContactValue { get; }
}
public class ContactEmailInfo : ContactInfo
{
public string EmailAddress { get; set; }
public override string ContactValue => EmailAddress;
}
public class ContactPhoneInfo : ContactInfo
{
public ulong PhoneNumber { get; set; }
public string RegionCode { get; set; }
public override string ContactValue => RegionCode;
}
public class UserDocument
{
public UserDocument()
{
ContactEmails = new List<ContactEmailInfo>();
ContactPhones = new List<ContactPhoneInfo>();
}
public IList<ContactEmailInfo> ContactEmails { get; }
public IList<ContactPhoneInfo> ContactPhones { get; }
[JsonIgnore]
public IReadOnlyCollection<ContactInfo> ContactInfos =>
new ReadOnlyCollection<ContactInfo>(ContactEmails
.Cast<ContactInfo>().Union(ContactPhones).ToArray());
}
from arangoclient.net.
Perfect, that is what I was looking for. Knowing about the embedded JSON.NET also helped me serialize enum
values as string
instead of int
, using
[ArangoDB.Client.Common.Newtonsoft.Json.JsonConverter(typeof(ArangoDB.Client.Common.Newtonsoft.Json.Converters.StringEnumConverter))]
public SomeEnum SomeEnumValue { get; set; }
from arangoclient.net.
let the issue be open till the bug is resolved
from arangoclient.net.
In current version (v0.7.60) still having this issue + new problem.
[ArangoDB.Client.Common.Newtonsoft.Json.JsonIgnore] can't be used because new ArangoDB has no "Common" namespace so i have used only [Newtonsoft.Json.JsonIgnore] which worked for some properties.
New problem:
i have following class (for tesing ArangoDB vs MongoDB:
`using ArangoDB.Client; //Nuget: ArangoDB.Client by raoof hojat v0.7.60
using MongoDB.Bson; //Nuget: MongoDB.Driver by MongoDB, Inc v2.3.0
public class Person
{
[DocumentProperty(Identifier = IdentifierType.Key)]
public string Key { get; set; }
public string Fullname { get; set; }
public int Age { get; set; }
// MongoDB
[DocumentProperty(IgnoreProperty = true)]//ignore for ArangoDB - not working - bug https://github.com/ra0o0f/arangoclient.net/issues/34
[Newtonsoft.Json.JsonIgnore] // proposed workaround for ArangoDB
public MongoDB.Bson.ObjectId _id { get; set; }
}`
and i whanted ArangoDB to ignore "_id"
but after
db.Insert<Person>(person);
i am catching an exception "Unable to cast object of type 'System.String' to type 'MongoDB.Bson.ObjectId'."
Callstack:
at lambda_method(Closure , Object , Object ) at ArangoDB.Client.Property.DocumentIdentifierModifier.Modify(Object document, IDocumentIdentifierResult identifiers) at ArangoDB.Client.Collection.ArangoCollection.<InsertAsync>d__10.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at ArangoDB.Client.Collection.ArangoCollection
1.d__10.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at ArangoDB.Client.Utility.TaskUtils.ResultSynchronizer[T](Task1 task)
Also this workaround is not working in all cases.
Is there any chance to fix this bug, because i want to give ArangoDB the chance ;) ?
from arangoclient.net.
Related Issues (20)
- Update fails with error "The given key was not present in the dictionary" when used on object retrieved via traversal.
- ArangoServerException not throw when db unavailable HOT 2
- Thread safety HOT 7
- Confused with SystemDatabaseCredential HOT 5
- Custom Index HOT 6
- ByExampleAsync missing HOT 2
- Make ChangeCollectionPropertyForType public HOT 1
- Using LINQ query with Where performance HOT 1
- Error in generated AQL when upserting a generic document HOT 7
- ArangoServerException eats up all the useful information like status code and error number HOT 2
- Make collection name resolver more extensible HOT 2
- Annotating a property of type Guid as DocumentProperty.Key throws InvalidCastException HOT 2
- Support private setter
- CreateStatement<object> & Remove Vertex HOT 1
- Ternary operator support
- Global error handling policy
- Support for keyOptions: uuid
- Edge Document API not supported?
- Cannot Simply Connect to Server...... HOT 2
- Secure connection to ArangoDB
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from arangoclient.net.