当前位置: 动力学知识库 > 问答 > 编程问答 >

c# - MongoRepository: Post data and Entity inherit is property empty

问题描述:

I am using this extension to generate repository for MongoDb.

https://github.com/RobThree/MongoRepository

I have created a model that inherits from Entity. And one that does not inherit from Entity.

The model that inherits from Entity instantiate the object but does not fill the property in the post request. See screenshots.

My model is like this:

public class EmailTransac : Entity

{ [Required()]

public string Name { get; set; }

[Required()]

public string From { get; set; }

[Required()]

public string Template { get; set; }

[Required()]

public string Subject { get; set; }

}

public class EmailTransacModel

{

[Required()]

public string Name { get; set; }

[Required()]

public string From { get; set; }

[Required()]

public string Template { get; set; }

[Required()]

public string Subject { get; set; }

}


With inherit of Entity

[][1


Without inherit of Entity

Would you know what can be the issue?

Thanks,

网友答案:

Ok I have fixed my problem.

For others if you struggle with this.

There is a DataContract in the base class. Hence we must add the attribute DataMember and it works!

[Required()]
[DataMember]
public string Name { get; set; }

Thanks

分享给朋友:
您可能感兴趣的文章:
随机阅读: