上手DocumentDB On Azure
Posted Capt2008
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了上手DocumentDB On Azure 相关的知识,希望对你有一定的参考价值。
无需像传统的JsonDataSerializer一样将每一个属性标上[DataMember]Attribute,只需重写Tostring方法,Newtonsoft.Json.JsonConvert.SerializeObject(this)会自动将Object属性写成Json文档,但需为键属性指定 [JsonProperty(PropertyName = "id")].
注意:
- 当DataObject存在继承关系时,JsonConvert只会序列化当前类的属性,而忽略其父类的属性,因此选择合适的数据类型很重要.
- 当DataObject继承自Document时,所有属性均需手动指定PropertyName,未指定的不会序列化;
- 主键id为string类型,id的propertyName必须声明为"id";
public override string ToString() { return Newtonsoft.Json.JsonConvert.SerializeObject(this); } |
在DashBoard中加载指标时报错??
查询操作:
给出的代码部分(https://www.azure.cn/documentation/articles/documentdb-get-started/#bookmark-7),分为了linq方法和sql方法,区别怎么说呢?自己看代码吧:
IQueryable<Family> familyQuery = this.client.CreateDocumentQuery<Family>
queryOptions .Where(f => f.LastName == "Andersen"); | IQueryable<Family> familyQueryInSql = this.client.CreateDocumentQuery<Family> UriFactory.CreateDocumentCollectionUri(databaseName, "SELECT * FROM Family WHERE Family.LastName = \'Andersen\'",
queryOptions |
但是,教程里说了:
The query is executed synchronously here, but can also be executed asynchronously via the
IDocumentQuery<T> interface.
来自 <https://www.azure.cn/documentation/articles/documentdb-get-started/>
而这个Interface下只有如下方法:
而且changeFeedQuery的查询参数在哪里??到底ChangeFeedQuery和FeedQuery有什么区别?回头再看吧.
搞完查,增,改,删操作,其主要逻辑是以client为对象操作数据库,这与MongoDB多少有点不同.
操作中使用最频繁的是:
- 定位Uri,包括定位Server的EndPointUri,Database的,DocumentCollection的,Document的,还有CollectionLink也是Uri.主要调用UriFactory.CreatexxxUri(string xxxId)方法;
- 所有的client下的操作主要就是调用Createxxx.,Readxxx,Deletexxx,Replacexxx,Excutexxx等方法来实现的;
- 所有的操作最重要的一个参数是feedOption和RequestOption;
- Collection十分重要,其索引的配置和设置是DocumentDB的灵魂,玩的好还是玩的砸就看这个了.
接下来就 是在UWP中使用Document了.目标用船舶数据进行测试.
这里就要考虑一致性的问题:两个客户端同时操作一条数据,以谁的为准?
权限分配原则
水尺业务员 | 经理 | 系统管理员 | 总经理 | 单证员 | 客户 |
|
1级读写 | 2级读写,宣布最终版(即锁定数据) | 不能在客户端正常读写,锁定,但可以解锁,以及在系统层面更改数据 | 解锁数据,2级读写???? | 读全部数据,不可写 | 读部分数据 |
|
如何缓存数据到本地留备用?
如何存图片等数据?
VslData Samples
No | Name | Type | IMO | Nationality | CrewList | Capacity | L*W | Description | KeyWord |
1 | ASIA SPIRIT | Bulk Carrier | 9637430 | Hongkong |
| 35031 | 179.9x28.4 | Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy "Tianjin Port" eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, | Tianjin port |
2 | AZURIT | Bulk Carrier | 9551703 | Portugal |
| 56771 | 189.9x32.2 | Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum."Tianjin Port" Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, | Tianjin port |
3 | GREEN PINE | General Car.. | 9100504 | Singapore |
| 8637 | 100.6x18.8 | Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et "TianJin Port" dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, | TianJin Port |
4 | HUAYANG SPIRIT | Bulk Carrier | 9591507 | Hongkong |
| 75784 | 224.9x32.2 | Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero "take berth" eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, | Take berth |
5 | KMARIN SINGAPO.. | Bulk Carrier | 9737357 |
|
| 63083 | 199.9x32.2 | Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, | none |
6 | LADY I | Bulk Carrier | 9336610 | Marshall Islands |
| 75356 | 224.9x32.2 | Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, | none |
7 | NORD CRUX | Bulk Carrier | 9728203 | Singapore |
| 81577 | 229x32.2 | Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd "take berth" gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, | Take berth |
8 | REDWING | Bulk Carrier | 9333931 | Saint Vincent and Grenadines |
| 53410 | 189.8x32.2 | Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, | none |
9 | SHUN QIANG 28 | Cargo ship | 856868910 | China |
|
| 150x21 | Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, | none |
10 | YANGTZE HARMONY | Bulk Carrier | 9618355 | Marshall Islands |
| 56763 | 189.9x32.2 | Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, | none |
来自 <https://docs.microsoft.com/zh-cn/azure/documentdb/documentdb-request-units>
以上是关于上手DocumentDB On Azure 的主要内容,如果未能解决你的问题,请参考以下文章
使用 Java SDK v2 com.microsoft.azure.documentdb 的 Azure Cosmos 自动缩放
通过php的MongoDB driver连接Azure的DocumentDB PaaS