IAzureCosmosDBV3Repository.cs 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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<T> DeleteAsync<T>(T entity) where T : ID;
  29. Task<T> DeleteAsync<T>(string id, string pk) where T : ID;
  30. Task DeleteAll<T>(List<T> entities) where T : ID;
  31. Task DeleteAll<T>(List<KeyValuePair<string, string>> ids) where T : ID;
  32. Task<T> Update<T>(T entity) where T : ID;
  33. Task<List<T>> UpdateAll<T>(List<T> entities) where T : ID;
  34. Task<T> SaveOrUpdate<T>(T entity) where T : ID;
  35. Task<List<T>> SaveOrUpdateAll<T>(List<T> entities) where T : ID;
  36. Task<T> FindById<T>(string id) where T : ID;
  37. Task<T> FindByIdPk<T>(string id, string pk) where T : ID;
  38. // Task<string> ReplaceObject<T>(T entity, string key, string partitionKey) where T : ID;
  39. Task<List<T>> FindAll<T>(List<string> propertys = null) where T : ID;
  40. /// <summary>
  41. /// QueryText = @"SELECT *
  42. // FROM c
  43. // WHERE c.documentType = @documentType
  44. // AND c.id = @id",
  45. //Parameters = new[]
  46. //{
  47. // new CosmosDbQueryParameter("@documentType", GetDocumentType<T>()),
  48. // new CosmosDbQueryParameter("@id", id)
  49. //}
  50. /// </summary>
  51. /// <typeparam name="T"></typeparam>
  52. /// <param name="sql"></param>
  53. /// <param name="Parameters"></param>
  54. /// <returns></returns>
  55. Task<List<T>> FindSQL<T>(string sql, Dictionary<string, object> Parameters = null, int itemsPerPage = -1, int? maxItemCount = null) where T : ID;
  56. //Task<List<T>> FindSQL<T>(string sql, bool isPK) where T : ID;
  57. /// <summary>
  58. /////正确的代码
  59. //Expression<Func<QuestionFeed, bool>> predicate = null;
  60. // query = f => 1==1;
  61. // query= query.And(x =>x.Address.City== "Seattle3");
  62. // query= query.Or(x => x.id== "Andersen.1");
  63. // query = query.And(x => x.Parents.Where(y => y.FirstName == "Thomas1").Any()) ;
  64. // Expression<Func<Family, object>> order = null;
  65. //order = f => f.id;
  66. //_questionFeedRepository.Entities.Where(predicate);
  67. /// </summary>
  68. /// <typeparam name="T"></typeparam>
  69. /// <param name="itemsPerPage"></param>
  70. /// <param name="query"></param>
  71. /// <returns></returns>
  72. 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;
  73. 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;
  74. 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;
  75. Task<List<dynamic>> FindByDict(string CollectionName, Dictionary<string, object> dict, int itemsPerPage = -1, int? maxItemCount = null, string partitionKey = null, List<string> propertys = null);
  76. Task<List<dynamic>> FindCountByDict(string CollectionName, Dictionary<string, object> dict, int itemsPerPage = -1, int? maxItemCount = null, string partitionKey = null);
  77. Task InitializeDatabase();
  78. }
  79. }