How to merge two lists by a unique field value and fill empty fields with values from one list?

Advertisements How to merge two lists by unique field value and fill empty fields with values ​​of one of the list? I have a class where unique field is Model_id: class Structure { public string Category { get; set; } public string Place { get; set; } public string Model_id { get; set; } public… Read More How to merge two lists by a unique field value and fill empty fields with values from one list?

How can I use AsAsyncEnumerable in Linq?

Advertisements I have this method: public async Task<List<string>> FindUsedComments(List<string> commentIds) { if (!commentIds.Any()) return new List<string>(); var usedCommentIds = GetNoTraking.Select(x => x.OrginalCommentId).AsEnumerable().Intersect(commentIds).ToList(); return usedCommentIds; } and it works fine! but if i change AsEnumerable to AsAsyncEnumerable it`s show me this error: ‘IAsyncEnumerable<string>’ does not contain a definition for ‘Intersect’ and the best extension method overload… Read More How can I use AsAsyncEnumerable in Linq?

Unexpected Guid change during a Linq request

Advertisements I would like to understand the following snippet: class TestNewGuid { public Guid RequestId { get; set; } = Guid.NewGuid(); // any other fields } [Fact] public void Test() { var toInitAnEnumerable = new int[] {1}; var requests = toInitAnEnumerable .Select(a => new TestNewGuid()); var requestIds = requests .Select(a => a.RequestId) .ToHashSet(); // this… Read More Unexpected Guid change during a Linq request

Why dynamic Linq does not work with .contains?

Advertisements I am creating dynamic query for linq using contains but I am not getting any results back. Results exists in SQL. What am I doing wrong here? Since I can have N values for columns, .Contains should be okay. Code: public IAsyncEnumerable<MyTable> GetMyTableRecordsPerFilter( IReadOnlyList<string> filters, CancellationToken cancellationToken) { var queryParams = generateQuery(filters); var query… Read More Why dynamic Linq does not work with .contains?