I have a c# Asp.Net Web API server and I make post requests to get Json respone
I am working with Linq and have 2 tables:
First is a forumMessage which each message point to specific user with accountId:
public partial class forumMessage
{
public int objectId { get; set; }
public string title { get; set; }
public string body { get; set; }
public int acountId { get; set; }//the user objectId
public virtual user user { get; set; }
}
Second is the user:
public partial class user
{
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")]
public user()
{
this.fora = new HashSet<forumMessage>();
}
public int objectId { get; set; }
public string username { get; set; }
public string password { get; set; }
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
public virtual ICollection<forumMessage> fora { get; set; }//list of messages
}
so what I need is to response a json array like:
[{
"$id": "1",
"objectId": 2,
"title": "Message Title",
"body": "Message body",
"acountId": 1,
"user": {
"$id": "2",
"objectId": 1,
"username": "Shay"
}}]
Notice that the respons is Without user password or the user list of messages Just some specific columns of user Thnx