如何创建一个Documentdb自动递增列 [英] How to create a auto incremented column in Documentdb
问题描述
我要创建与自动增量列蔚蓝documentdb的文件。
这是可能的,如果是的话,请指导我。
任何帮助将是很大很大的。
数据库DB = CreateOrReadDocumentDb(EmployeeDb) 。结果;
DocumentCollection DC = CreateOrReadDocumentCollection(db.SelfLinkEmployeeDetails)结果。
员工EMP =新员工();
emp.Name =ABC;
emp.id =; //自动生成一个唯一的字符串
emp.sal = 10000;
emp.exp = 5;
emp.index = 0; //我想与人名索引EMP一个自动递增列并希望在蔚蓝的文件DB
client.CreateDocumentAsync(collectionLink,数据)来存储;
DocumentDB不包括自动递增的功能出框。
由于拉夫中的我们是否有DocumentDB 标识列中, ID
字段是在特殊的一个值不是由应用程序提供 - DocumentDB将分配。自动将GUID
如果你需要自动增加的功能 - 一个潜在的解决方案是将存储柜作为文档和杠杆的DocumentDB's触发来填充你的领域,并更新计数器。
I want to create a document in azure documentdb with a column of auto increment.
Is this possible, If yes, please guide me.
Any help would be greatly appreciable.
Database db = CreateOrReadDocumentDb("EmployeeDb").Result;
DocumentCollection dc = CreateOrReadDocumentCollection(db.SelfLink, "EmployeeDetails").Result;
Employee emp = new Employee();
emp.Name="ABC";
emp.id="";//automatically generate a unique string
emp.sal=10000;
emp.exp =5;
emp.index=0; // I want an auto increment column for emp with name index and want to store in azure document db
client.CreateDocumentAsync(collectionLink, data);
DocumentDB doesn't include auto-increment functionality out of the box.
As Gaurav mentioned in Do we have Identity Column in DocumentDB, the id
field is special in that if a value isn't provided by the application - DocumentDB will assign a GUID automatically.
If you need auto-increment functionality - one potential solution would be to store a counter as a document and leverage DocumentDB's triggers to populate your field and update the counter.
这篇关于如何创建一个Documentdb自动递增列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!