Combining two separate linq queries

I have a LINQ query that results in an array of Job records. Due to LINQ-To-SQL restrictions / limitations regarding cross-context queries, I cannot connect to the table, so the two fields for the Job entry are empty.

However, I can get them by doing a separate LINQ query.

My question is: can I fill in these two fields, it’s easy to say, for example, by combining these two queries? - And if so, how?

query1.Join(query2,..... and so on);

Thanks in advance.

EDIT

var results = query1.Join(query2,
                        job => job.JobID,
                        other => other.JobID,
                        (job, other) => new
                        {
                            MissingField = other.Field,
                            OtherMissingField = other.OtherField
                        });

I get an error: Type arguments for the method "System.Linq.Enumerable.Join (System.Collections.Generic.IEnumerable, System.Collections.Generic.IEnumerable, System.Func, System.Func, System.Func)" cannot be taken out of use. Try explicitly specifying type arguments.

+3
1

, , LINQ-to-Objects; .ToList() .AsEnumerable() - LINQ, , .

; . , TSQL . LINQ-to-SQL ExecuteQuery<T> .

+2

Source: https://habr.com/ru/post/1791457/


All Articles