示例#1
0
        public async Task <ICollection <CipherDetails> > GetManyByTypeAndUserIdAsync(Enums.CipherType type, Guid userId)
        {
            using (var connection = new SqlConnection(ConnectionString))
            {
                var results = await connection.QueryAsync <CipherDetails>(
                    $"[{Schema}].[CipherDetails_ReadByTypeUserId]",
                    new
                {
                    Type   = type,
                    UserId = userId
                },
                    commandType : CommandType.StoredProcedure);

                return(results.ToList());
            }
        }
示例#2
0
        public async Task <ICollection <CipherDetails> > GetManyByTypeAndUserIdAsync(Enums.CipherType type, Guid userId)
        {
            using (var connection = new SqlConnection(ConnectionString))
            {
                var results = await connection.QueryAsync <CipherDetails>(
                    $"[{Schema}].[CipherDetails_ReadByTypeUserId]",
                    new
                {
                    Type   = type,
                    UserId = userId
                },
                    commandType : CommandType.StoredProcedure);

                // Return distinct Id results. If at least one of the grouped results allows edit, that we return it.
                return(results
                       .GroupBy(c => c.Id)
                       .Select(g => g.OrderByDescending(og => og.Edit).First())
                       .ToList());
            }
        }