[英]Design Query on Azure Table Storage
I have 2 C# MVC models 我有2个C#MVC模型
SignalModel
==> contains the properties of Signal say MasterSignal SignalModel
==> 包含信号属性,例如MasterSignal
DeviceSignalModel
==> contains all signal properties pertaining to a Device DeviceSignalModel
==> 包含与设备有关的所有信号属性
So both are expected to have same properties except that DeviceSignalModel
need to have an additional property of DeviceID. 因此,除了DeviceSignalModel
需要具有DeviceID的其他属性外,两者DeviceSignalModel
具有相同的属性。
The Model SignalModel
will have columns ==> id,name,unit,range ... representing the Azure Storage Table signal
. Model SignalModel
将具有==> id,name,unit,range ...列,它们代表Azure存储表signal
。
I use below to get the data from table signal
我用下面从表signal
获取数据
TableOperation retOp = TableOperation.Retrieve<SignalModel>(..,..,..);
TableResult tr = table.Execute(retOp);
I have another Azure Storage Table devicesignal
and its represented by a model DeviceSignalModel
I have designed the Model as 我有另一个Azure存储表devicesignal
,它由模型DeviceSignalModel
表示,我已将模型设计为
public class DeviceSignalModel : TableEntity, IAzureTableStorage
{
//public int DeviceSignalKey { get; set; }// RowKey for Unique Key
//public string DeviceSignalID { get; set; }// PartitionKey of Storage Table Device
public SignalModel Signal { get; set; }//<===== (A) Model here right?
And to get data from devicesignal I use the below 为了从devicesignal获取数据,我使用以下内容
TableOperation retOp = TableOperation.Retrieve<DeviceSignalModel>(..,..,..);
TableResult tr = table.Execute(retOp);
With the above query I don't get values of columns represented within SignalModel from devicesignal table(statement (A) above). 通过上面的查询,我无法从devicesignal表(上述声明(A))中获取SignalModel中表示的列的值。 I get a null for property Signal. 我得到的属性Signal为空。
My Query 我的查询
1.Is the statement (A) in above snippet not possible? 1.以上代码段中的(A)语句不可能吗?
You can not make your custom SignalModel
as Property type. 您不能将自定义SignalModel
为Property类型。 If you want to maintain SignalModel
type object information in a DeviceSignalModel
entity, you can try to serialize the SignalModel
type object into JSON string and save it as property value of DeviceSignalModel
entity. 如果要在DeviceSignalModel
实体中维护SignalModel
类型对象信息,则可以尝试将SignalModel
类型对象序列化为JSON字符串,并将其另存为DeviceSignalModel
实体的属性值。 Or as davethecoder said, if possible, you can use Azure DocumentDB to store your data. 或如davethecoder所说,如果可能,您可以使用Azure DocumentDB存储数据。
Besides, to implement relationships between Signal and DeviceSignal in Azure Table service, as you mentioned, placing particular properties of SignalModel entity inside the DeviceSignalModel entity could be a approach. 此外,如前所述,要在Azure Table服务中实现Signal与DeviceSignal之间的关系,可以将SignalModel实体的特定属性放在DeviceSignalModel实体内部。 In addition, you can refer to this article to know about modelling relationships and table design patterns in Azure Table service. 此外,您可以参考本文以了解有关Azure表服务中的建模关系和表设计模式的信息。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.