c# - Azure Document DB UpdateDoc -



c# - Azure Document DB UpdateDoc -

i starting off azure document db. trying update existing document. when utilize next query works:

dynamic team2doc = client.createdocumentquery<document>(documentcollection.documentslink).where(d => d.id == "t002").asenumerable().firstordefault(); team2doc.teamname = "updated_team_2"; await client.replacedocumentasync(team2doc);

but if utilize below code:

dynamic team2doc = client.createdocumentquery<document>(documentcollection.documentslink).where(d => d.teamname== "team1").asenumerable().firstordefault(); team2doc.teamname = "updated_team_2"; await client.replacedocumentasync(team2doc);

i error:

"the best overloaded method match 'microsoft.azure.documents.client.documentclient.replacedocumentasync(microsoft.azure.documents.document, microsoft.azure.documents.client.requestoptions)' has invalid arguments"

is there anyway retrieve document 1 of properties , update document?

the clause trying query property teamname not exist in document class.

changing type of queryable info model should prepare it.

for example, have next info model:

public class employeedocument : document { // other properties may have defined .... public class string teamname { { homecoming this.getvalue<string>("teamname"); } set { this.setvalue("teamname", value); } } }

then can modify query this:

var team2doc = client.createdocumentquery<employeedocument>(documentcollection.documentslink).where(d => d.teamname== "team1").asenumerable().firstordefault(); team2doc.teamname = "updated_team_2"; await client.replacedocumentasync(team2doc);

note have utilize employeedocument, instead of document class, while creating document queryable. allow query on employeedocument properties.

sql version

creating document model each of existing info models may not feasible if have big number of info models. in case may want seek out sql query syntax.

refer aravind's reply in post. illustration uses deleting documents, can modified update them too.

c# azure azure-documentdb

Comments

Popular posts from this blog

java - How to set log4j.defaultInitOverride property to false in jboss server 6 -

c - GStreamer 1.0 1.4.5 RTSP Example Server sends 503 Service unavailable -

Using ajax with sonata admin list view pagination -