ict_misi
(Willem den Houdijker)
February 27, 2023, 10:22pm
1
How can I connect to MSSQL database Views?
wlandgraf
(Wagner Landgraf)
February 28, 2023, 1:28pm
2
You can map views just the way you map tables. Use the name of the view in the Table
attribute and use it normally. Of course, you would not be able to update data using those entities, just read data.
More references:
You can map an entity to the view the same way you do with a table, just put the name of the view in the [Table] attribute, and Aurelius will perform a SELECT FROM <view_name> statement. But, of course, that entity will be read-only, you will not be able to execute data modification operations on it.
View approach is possible. Another option is to use multi-model design , having separated classes with less fields, in a different model, and simply use that different model to retrieve data.
Multi-model approach is also used to logically separate the classes that should be used to update the database, and those which won't.
Hi Jason, you're welcome! That's what you should do, create a regular entity class (manually) and then set the view name as the "table" name in [Table] attribute!
You can use both custom interfaces or create entities mapped to the views to retrieve data just as you would do with tables. But there is no automatic entity generator for views, you will have to create the classes manually.