IAzureCosmosDBV3Repository.cs 4.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq.Expressions;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. namespace TEAMModelOS.SDK.Module.AzureCosmosDBV3
  7. {
  8. /// <summary>
  9. /// "$.name":"明",
  10. /// "!$.name":"小"
  11. /// "code.|":{"aaa"}
  12. /// "<.birthday":20150101,
  13. /// "!=.type":"测试",
  14. /// "<=.day":"1515"
  15. /// ">.age.&":18,
  16. /// "codes[*]":{"aaa"}
  17. /// "codes[*]":["aaa","bbb"]
  18. /// "code":["aaa","bbb"]
  19. /// "@OFFSET":1,
  20. /// "@LIMIT":10,
  21. /// "@DESC","crateTime"
  22. /// "@ASC","crateTime"
  23. /// </summary>
  24. public interface IAzureCosmosDBV3Repository
  25. {
  26. Task<T> Save<T>(T entity) where T : ID;
  27. Task<List<T>> SaveAll<T>(List<T> enyites) where T : ID;
  28. Task<IdPk> DeleteAsync<T>(T entity) where T : ID;
  29. Task<IdPk> DeleteAsync<T>(string id, string pk) where T : ID;
  30. Task<IdPk> DeleteAsync<T>(IdPk idPk) where T : ID;
  31. Task<List<IdPk>> DeleteAll<T>(List<T> entities) where T : ID;
  32. Task<List<IdPk>> DeleteAll<T>(List<IdPk> ids) where T : ID;
  33. Task<List<IdPk>> DeleteAll<T>(Dictionary<string, object> dict) where T : ID;
  34. Task<T> Update<T>(T entity) where T : ID;
  35. Task<List<T>> UpdateAll<T>(List<T> entities) where T : ID;
  36. Task<T> SaveOrUpdate<T>(T entity) where T : ID;
  37. Task<List<T>> SaveOrUpdateAll<T>(List<T> entities) where T : ID;
  38. // Task<T> FindById<T>(string id) where T : ID;
  39. Task<T> FindByIdPk<T>(string id, string pk) where T : ID;
  40. // Task<string> ReplaceObject<T>(T entity, string key, string partitionKey) where T : ID;
  41. Task<List<T>> FindAll<T>(List<string> propertys = null) where T : ID;
  42. /// <summary>
  43. /// QueryText = @"SELECT *
  44. // FROM c
  45. // WHERE c.documentType = @documentType
  46. // AND c.id = @id",
  47. //Parameters = new[]
  48. //{
  49. // new CosmosDbQueryParameter("@documentType", GetDocumentType<T>()),
  50. // new CosmosDbQueryParameter("@id", id)
  51. //}
  52. /// </summary>
  53. /// <typeparam name="T"></typeparam>
  54. /// <param name="sql"></param>
  55. /// <param name="Parameters"></param>
  56. /// <returns></returns>
  57. Task<List<T>> FindSQL<T>(string sql, Dictionary<string, object> Parameters = null, int itemsPerPage = -1, int? maxItemCount = null) where T : ID;
  58. //Task<List<T>> FindSQL<T>(string sql, bool isPK) where T : ID;
  59. /// <summary>
  60. /////正确的代码
  61. //Expression<Func<QuestionFeed, bool>> predicate = null;
  62. // query = f => 1==1;
  63. // query= query.And(x =>x.Address.City== "Seattle3");
  64. // query= query.Or(x => x.id== "Andersen.1");
  65. // query = query.And(x => x.Parents.Where(y => y.FirstName == "Thomas1").Any()) ;
  66. // Expression<Func<Family, object>> order = null;
  67. //order = f => f.id;
  68. //_questionFeedRepository.Entities.Where(predicate);
  69. /// </summary>
  70. /// <typeparam name="T"></typeparam>
  71. /// <param name="itemsPerPage"></param>
  72. /// <param name="query"></param>
  73. /// <returns></returns>
  74. Task<List<T>> FindLinq<T>(Expression<Func<T, bool>> query = null, Expression<Func<T, object>> order = null, bool isDesc = false, int itemsPerPage = -1, int? maxItemCount = null) where T : ID;
  75. Task<List<T>> FindByParams<T>(Dictionary<string, object> dict, int itemsPerPage = -1, int? maxItemCount = null, string partitionKey = null, List<string> propertys = null) where T : ID;
  76. Task<List<T>> FindByDict<T>(Dictionary<string, object> dict, int itemsPerPage = -1, int? maxItemCount = null, string partitionKey = null, List<string> propertys = null) where T : ID;
  77. Task<List<dynamic>> FindByDict(string CollectionName, Dictionary<string, object> dict, int itemsPerPage = -1, int? maxItemCount = null, string partitionKey = null, List<string> propertys = null);
  78. Task<List<dynamic>> FindCountByDict(string CollectionName, Dictionary<string, object> dict, int itemsPerPage = -1, int? maxItemCount = null, string partitionKey = null);
  79. Task InitializeDatabase();
  80. Task<T>FindById<T>(string id) where T : ID;
  81. Task<List<T>> FindByIds<T>(List<string> ids) where T : ID;
  82. Task<dynamic> FindById(string CollectionName, string id);
  83. Task<List<dynamic>> FindByIds (string CollectionName, List<string> ids);
  84. }
  85. }