Skip to content

Business logic inside queries  #6749

@gmatv

Description

@gmatv

One question bothers me when I see such code inside queries

SUM(oi.units*oi.unitprice) as total

Isn't it a part of business logic and we have duplication here? Yes, in this case it looks simple but imagine if it will invovle, for example, discount system.

To compare, the same in domain model: Order.cs

    public decimal GetTotal()
    {
        return _orderItems.Sum(o => o.GetUnits() * o.GetUnitPrice());
    }

Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions