IAzureCosmosDBV3Repository.cs 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. public interface IAzureCosmosDBV3Repository
  9. {
  10. Task<T> Save<T>(T entity) where T : ID;
  11. Task<List<T>> SaveAll<T>(List<T> enyites) where T : ID;
  12. Task<T> DeleteAsync<T>(T entity) where T : ID;
  13. Task<T> DeleteAsync<T>(string id, string pk) where T : ID;
  14. Task DeleteAll<T>(List<T> entities) where T : ID;
  15. Task DeleteAll<T>(List<KeyValuePair<string, string>> ids) where T : ID;
  16. Task<T> Update<T>(T entity) where T : ID;
  17. Task<List<T>> UpdateAll<T>(List<T> entities) where T : ID;
  18. Task<T> ReplaceObject<T>(T entity) where T : ID;
  19. Task<T> FindById<T>(string id) where T : ID;
  20. Task<T> FindByIdPk<T>(string id, string pk) where T : ID;
  21. // Task<string> ReplaceObject<T>(T entity, string key, string partitionKey) where T : ID;
  22. Task<List<T>> FindAll<T>() where T : ID;
  23. /// <summary>
  24. /// QueryText = @"SELECT *
  25. // FROM c
  26. // WHERE c.documentType = @documentType
  27. // AND c.id = @id",
  28. //Parameters = new[]
  29. //{
  30. // new CosmosDbQueryParameter("@documentType", GetDocumentType<T>()),
  31. // new CosmosDbQueryParameter("@id", id)
  32. //}
  33. /// </summary>
  34. /// <typeparam name="T"></typeparam>
  35. /// <param name="sql"></param>
  36. /// <param name="Parameters"></param>
  37. /// <returns></returns>
  38. Task<List<T>> FindSQL<T>(string sql, Dictionary<string, object> Parameters = null, int itemsPerPage = -1, int? maxItemCount = null) where T : ID;
  39. //Task<List<T>> FindSQL<T>(string sql, bool isPK) where T : ID;
  40. /// <summary>
  41. /////正确的代码
  42. //Expression<Func<QuestionFeed, bool>> predicate = null;
  43. // query = f => 1==1;
  44. // query= query.And(x =>x.Address.City== "Seattle3");
  45. // query= query.Or(x => x.id== "Andersen.1");
  46. // query = query.And(x => x.Parents.Where(y => y.FirstName == "Thomas1").Any()) ;
  47. // Expression<Func<Family, object>> order = null;
  48. //order = f => f.id;
  49. //_questionFeedRepository.Entities.Where(predicate);
  50. /// </summary>
  51. /// <typeparam name="T"></typeparam>
  52. /// <param name="itemsPerPage"></param>
  53. /// <param name="query"></param>
  54. /// <returns></returns>
  55. 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;
  56. Task<List<T>> FindByParams<T>(Dictionary<string, object> dict, int itemsPerPage = -1, int? maxItemCount = null, string partitionKey = null) where T : ID;
  57. Task<List<T>> FindByDict<T>(Dictionary<string, object> dict, int itemsPerPage = -1, int? maxItemCount = null, string partitionKey = null) where T : ID;
  58. Task<List<dynamic>> FindByDict(string CollectionName, Dictionary<string, object> dict, int itemsPerPage = -1, int? maxItemCount = null, string partitionKey = null);
  59. Task<List<dynamic>> FindCountByDict(string CollectionName, Dictionary<string, object> dict, int itemsPerPage = -1, int? maxItemCount = null, string partitionKey = null);
  60. Task InitializeDatabase();
  61. }
  62. }