Hi, I’m working on an invoicing SaaS system where each user has its data stored in the same table.
An “Invoice” table is storing invoices of all database users.
To filter their invoices, I use a UserId field which is requested each time a SqlExpression is called in the code (so I call it manually).
Since there is not only invoices but other tables with UserId field, I would like to know if there is a better way to do this.
I mean I could use an interface like IHasUserId for each class with a UserId field, and I was thinking that maybe I can add automatically a SqlExpression.Where(p => p.UserId == UserSession.Id) each time a SqlExpression of a IHasUserId class is called.