Table of Contents

This page has been moved, the new location is https://korzh.com/easyquery/docs/how-to/add-virtual-attribute-in-model?.

Virtual attributes

What are they for

There are 2 types of entity attributes in each data model:

The main advantage of virtual attribute is that your will not need to type full expression each type they would like to see such column in result set or to use that expression in a query condition. They just can select this attribute (either in columns or conditions) the same way as they do for any other entity attribute in your model. EasyQuery will do the rest of the jobs automatically: it will add necessary table(s) into result SQL, join them with other tables used in that query and add the expression defined for virtual attribute either in SELECT or WHERE clause.

How to add

1. Run Data Model Editor and open your model there.

2. Go to the Entities tab and select the entity node where you would like to add new virtual attribute.

3. Right click on that node and select “Add virtual attribute” menu item.

4. Then you will need to define main properties of new attribute:

5. Finally you need to define the list of operators which can be used with your attribute in conditions. Open “Operators” tab for your attribute (don't confuse it with global Operators tab - the one you need is inside “Entity / attribute properties” panel) and click on “Defaults” button to get default list of operators suitable for this attribute. Of course you can skip this step of you don't plan to use this attribute in conditions (“Use in conditions” option is turned off).

6. That's all. Save your model and tell you users about new attribute they can use in their queries.