Search code examples
c#azureazureservicebusservicebus

How to deserialize service bus message SystemProperties.LockToken into own class c#?


I have below code to de-serialize message properties into my own class but how to get default message properties into that same class?

 var data = Encoding.UTF8.GetString(message.Body);
 var testdata = JsonConvert.DeserializeObject<MyClass>(data); 

I want this message property also into MyClass message.SystemProperties.LockToken

 public class CheckException
    {
        public Guid Id { get; set; }
        public string Name { get; set; }

Solution

  • LockToken is a string property in Message.SystemPropertiesCollection(), you can assign the SystemProperties.LockToken as

     CheckException checkException = new CheckException();
     checkException.LockToken = message.SystemProperties.LockToken;