I would like to use such an entity to store tables:
public class MyEntity { public String Text { get; private set; } public Int32 SomeValue { get; private set; } public MyEntity(String text, Int32 someValue) { Text = text; SomeValue = someValue; } }
But this is not possible because ATS needs
- Constructor without parameters
- All objects are public and read / write.
- Inherit from TableServiceEntity;
The first two, two things that I do not want to do. Why should I want someone to change some read-only data? or create objects of this kind in an inconsistent manner (what is .ctor for this?), or even worse, change PartitionKey or RowKey. Why are we still limited by these deserialization requirements?
I don't like designing software this way, how can I use a table storage library so that I can serialize and deserialize myself? I think as long as objects inherit from TableServiceEntity, this should not be a problem.
For now I need to save the object, but I do not know how to get it:
Message m = new Message("message XXXXXXXXXXXXX"); CloudTableClient tableClient = account.CreateCloudTableClient(); tableClient.CreateTableIfNotExist("Messages"); TableServiceContext tcontext = new TableServiceContext(account.TableEndpoint.AbsoluteUri, account.Credentials); var list = tableClient.ListTables().ToArray(); tcontext.AddObject("Messages", m); tcontext.SaveChanges();
Is there a way to avoid these deserialization requirements or get a raw object?
Greetings.
source share