none
Query IReliableDictionay2 based on text a matching to values instead of keys. RRS feed

  • Question

  • I have a WEB API application using Service fabric reliable collection as a data base.

    I want to query the IReliableDictionary2 based on text matching to one of the properties of the value.

    I mean i want to search the whole objects whose one its property matching with the input text.

    private const string TagsDictionary = "Tags";
    
    var tags = await _stateManager.GetOrAddAsync<IReliableDictionary2<string, Tag>>(TagsDictionary);
    
    using (var transaction = _stateManager.CreateTransaction())
                    {                  
                        var allTags = await tags.CreateEnumerableAsync(transaction,
                                          tagName =>
                                            {
                                         
                                                var matchResult = Regex.IsMatch(tagName, searchPattern, RegexOptions.Compiled);
                                               
                                                if (matchResult)
                                                    ++tagMatchCount;
                                               
                                                   
                                                
    
                                               
    
                                                return matchResult;
                                            },
                                            EnumerationMode.Ordered);
    
     using (var enumerator = allTags.GetAsyncEnumerator())
                            {
                                while (await enumerator.MoveNextAsync(CancellationToken.None))
                                {
                                    if (result.Count < tagResourceParameters.PageSize
                                        && skipIndexCount < tagMatchCount)
                                    {
                                        result.Add(enumerator.Current.Value);
                                        ++skipIndexCount;
                                    }
                                }
                            }
    
                       

    In the above code i can able to query based on only input text matching to keys but i want to query the values based on its property matching to input text

    Monday, December 16, 2019 12:04 PM

All replies

  • Hi SiddharthVaish,

    Thank you for posting here.

    According to your description, your issue is more related to azure service fabric. Therefore, it will be more appropriate to ask your question in Azure Service Fabric Forums

    The CLR Forum discuss and ask questions about .NET Framework Base Classes (BCL) such as Collections, I/O, Regigistry, Globalization, Reflection. Also discuss all the other Microsoft libraries that are built on or extend the .NET Framework.

    Thank you for your understanding.

    Best Regards,

    Xingyu Zhao


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, December 17, 2019 7:45 AM