Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I've managed to find the solution:</p> <p>The selfmade class( in my case: Subscription) has to be inherited from a custom TableServiceEntity class, which has datacontract, datamember and knowntype attributes:</p> <pre><code>[DataContract] [KnownType(typeof(Subscription))] public abstract class SerializableTableServiceEntity { [DataMember] public string PartitionKey { get; set; } [DataMember] public string RowKey { get; set; } [DataMember] public DateTime Timestamp { get; set; } } [DataContract] public class Subscription : SerializableTableServiceEntity { [DataMember] public string SubscriptionId { get; set; } [DataMember] public bool IsAdmin { get; set; } } </code></pre> <p>And the key is that: <strong>You don't send the result back as an HttpResponseMessage</strong> It will always be an HttpResponseMessage no matter what your return type is. If your return type is an IList, then it will be serialized and will be put in the response's body automatically. So just send it back the way it is. If you want to modify the statuscode of the reply, you can get it done like this:</p> <pre><code>WebOperationContext.Current.OutgoingResponse.StatusCode = HttpStatusCode.Forbidden; </code></pre> <p>You can get/set everything from the request/reponse body/header from </p> <p>WebOperationContext.Current</p> <p>I hope it helps!</p> <p><strong>Addition:</strong></p> <p>But be aware, that if you get your selfmadeclass(in my case subscription) type of object from the azure database, you won't be able to delete it:</p> <pre><code>Subscription s = (from e in this.CreateQuery&lt;Subscription&gt;("Subscriptions") where e.SubscriptionId == subscriptionID select e).FirstOrDefault(); context.DeleteObject(s); //THIS WILL THROW AN EXCEPTION </code></pre> <p>instead the return type has to something that is inherited from the TableServiceEntity, and you can only delete that.</p> <p>Please, if I'm wrong, update this post!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload