Using a partial class property inside LINQ statement

后端 未结 6 866
灰色年华
灰色年华 2020-12-05 10:39

I am trying to figure out the best way to do what I thought would be easy. I have a database model called Line that represents a line in an invoice.

It looks roughly

6条回答
  •  抹茶落季
    2020-12-05 11:00

    While not an answer to your subject, it may be an answer to your problem:

    Since you seem willing to modify the database, why not create a new View in the database that is basically

    create view TotalledLine as
    select *, Total = (Price * Quantity)
    from LineTable;
    

    and then change your data model to use TotalledLine instead of LineTable?

    After all, if your application needs Total, it isn't a stretch to think others might, and centralizing that type of calculation into the database is one reason for using a database.

提交回复
热议问题