A
A
Andrew2019-01-28 19:52:43
.NET
Andrew, 2019-01-28 19:52:43

How to decorate Expression?

Asp.Net MVC, MS Sql, Entity Framework
There is a query that aggregates a dozen large tables. It looks something like this:

_db.Table.Where(t=>...)
  .Select(t=>new Model{
    Field1 = t.SomeTable.Field
    Field2 = t.SomeTable2.Field
    ...итд, около 30ти полей...}).ToList();

It all works not very fast, the load on the database creates a noticeable load.
The question is this:
It often happens that some fields are not needed, and, accordingly, it is not necessary to aggregate some tables, and therefore it is necessary to make a "basic" Expression and decorate it with the necessary additional fields.
It is theoretically possible to simply describe all possible options, but the variability is large.
Is there any way to decorate an Expression? Or any other ideas how to solve this problem?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander Yudakov, 2019-01-28
@byte916

Problems like this come up on a regular basis. I build the text of the SQL query manually, without any Linq to SQL.
Depending on the current needs, I include in the text of the SQL query those tables, conditions, groupings, etc. that are needed.

D
Dmitry Korolev, 2019-02-16
@adressmoeistranici

need to create stored procedures

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question