简体   繁体   中英

Virtual property in Entity Framework or SQL Server join using view

I have a model that has many navigation properties to other poco models. I was wondering that replacing it with a SQL view that join all these tables by foreign keys into one respecting model to get all data that I need in one trip will boost performance. Any tips will be appreciated.

In your case using an Indexed View likely would improve read-performance, so it's worth evaluating. If you have the ability to alter the database structure then you may also consider using EF's ComplexType feature to map many related classes to a single db row--avoiding the need to join altogether.

When working with an ORM it's important to keep in mind that the design of your C# model and your database typically do not have to be the same; so you can build a performant database as well as a reasonable C# model with minimal compromise.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM