|
@@ -61,6 +61,7 @@ namespace HaBookCms.AzureCosmos.CosmosDB.Implements
|
|
|
await InitializeCollection<T>();
|
|
|
ResourceResponse<Document> doc =
|
|
|
await CosmosClient.CreateDocumentAsync(UriFactory.CreateDocumentCollectionUri(_Database, t.Name), entity);
|
|
|
+ Console.WriteLine(doc.ActivityId);
|
|
|
return (T)entity;
|
|
|
}
|
|
|
|
|
@@ -77,7 +78,7 @@ namespace HaBookCms.AzureCosmos.CosmosDB.Implements
|
|
|
{
|
|
|
Type t = typeof(T);
|
|
|
List<T> objs = new List<T>();
|
|
|
- await InitializeCollection<T>();
|
|
|
+ //await InitializeCollection<T>();
|
|
|
//查询条数 -1是全部
|
|
|
FeedOptions queryOptions = new FeedOptions { MaxItemCount = -1 };
|
|
|
var query = CosmosClient.CreateDocumentQuery<T>(UriFactory.CreateDocumentCollectionUri(_Database, t.Name), queryOptions).AsDocumentQuery();
|
|
@@ -108,18 +109,17 @@ namespace HaBookCms.AzureCosmos.CosmosDB.Implements
|
|
|
|
|
|
}
|
|
|
|
|
|
- public async Task<List<T>> FindSQL<T>(string sql)
|
|
|
+ public List<dynamic> FindSQL<dynamic>(string sql)
|
|
|
{
|
|
|
- Type t = typeof(T);
|
|
|
- List<T> objs = new List<T>();
|
|
|
- await InitializeCollection<T>();
|
|
|
- var query = CosmosClient.CreateDocumentQuery<T>(UriFactory.CreateDocumentCollectionUri(_Database, t.Name),sql);
|
|
|
- foreach (var item in query.ToList())
|
|
|
+ Type t = typeof(dynamic);
|
|
|
+ List<dynamic> objs = new List<dynamic>();
|
|
|
+ //await InitializeCollection<T>();
|
|
|
+ var query = CosmosClient.CreateDocumentQuery<dynamic>(UriFactory.CreateDocumentCollectionUri(_Database, t.Name),sql);
|
|
|
+ foreach (var item in query)
|
|
|
{
|
|
|
- Console.WriteLine(JsonConvert.SerializeObject(item));
|
|
|
+ objs.Add(item);
|
|
|
}
|
|
|
return objs;
|
|
|
- //return CosmosClient.CreateDocumentQuery<T>(UriFactory.CreateDocumentCollectionUri(_Database, t.Name),sql);
|
|
|
|
|
|
}
|
|
|
}
|