new { a, b, c, d, l } creates an element of an anonymous type , so the return value of a full LINQ query also results in an anonymous type. To pass such a value in a method, I would suggest converting it to a known type. Just enter a new class and interface if you want to abstract the method from a specific implementation:
It is unclear which request is executing and what types of elements are the class and type of update, respectively:
interface IResultSet { TypeA A { get; } TypeB B { get; } TypeC C { get; } TypeD D { get; } TypeL L { get; } } class ResultSet : IResultSet { public ResultSet(inject all property values here) {} public TypeA A { get; private set; } public TypeB B { get; private set; } public TypeC C { get; private set; } public TypeD D { get; private set; } public TypeL L { get; private set; } } IEnumerable<IResultSet> sets = from a in patient from b in patient from c in patient from d in patient from l in patient where a.VisitNum < b.VisitNum && b.VisitNum < c.VisitNum && c.VisitNum < d.VisitNum && d.VisitNum < l.VisitNum select new ResultSet(a, b, c, d, l);
And keep in mind that LINQ Select() divided the execution, so the query itself will not be executed until you get access to the enumeration of the result set, so if you need to execute it immediately, just add the .ToList() call to end of request:
Deffered:
ProcessData(sets);
Immediate execution:
ProcessData(sets.ToList());
And finally, I would suggest NOT using the dynamic type to abstract such anonymous types, you can use it, but in some special cases, so this will be an adequate solution. In your case, this will make the code less readable and break security type, dynamic great for DSL engines and things for processing dynamic structure data, but not to be a silver bullet for those who do not know the basics of OOP very well.
source share