Quantcast
Channel: DreamFactory Forum - Latest posts
Viewing all articles
Browse latest Browse all 5028

.NET SDK create record Unique Constraint

$
0
0

Dont know whether it is my environment or not :S

I added a conditional Property Serialization attribute to the StaffRecord Poco/DTO

internal class StaffRecord
{

        public bool ShouldSerializeUid()
        {
            return Uid != 0;
        }

        public int Uid { get; set; }

        public string FirstName { get; set; }
        public string LastName { get; set; }
        public int Age { get; set; }
        public bool Active { get; set; }

        public override string ToString()
        {
            return string.Format("{0}: name = {1} {2}, age = {3}, active = {4}", Uid, FirstName, LastName, Age, Active);
        }
    }

This now works as expected on both serialization/deserialization

Here is the docs in teh JSON.NET docs
Conditional Property Serialization

Cheers :smiley:


Viewing all articles
Browse latest Browse all 5028

Trending Articles