Load Methods that Utilize Database Indexes
As you saw in the previous example, the Code Generator will always generate two load methods, Load and LoadAll, for every code generated class. Load takes in the primary key (or primary keys if you have multiple PKs defined on the table) as the parameter, while LoadAll simply returns all the rows in the table.Using database indexes, the code generator will also generate additional Load-type methods given the way you have defined those indexes. In our Examples Site Database, there are quite a few indexes defined, but we will highlight two:
- person.last_name
- login.username (UNIQUE)
Note that the LastName load method returns an array while the Username load method returns just a single object. The code generator has recognized the UNIQUE property on the column, and it generated code accordingly.
You could also define indexes on multiple columns and the code generator will generate load methods based on those multi-column keys.
Using LoadByUsername to get a Single Login Object
Login ID: 1Login Username: jdoe
Login Password: p@$$.w0rd
Using LoadArrayByLastName to get an Array of Person Objects
• Alex Smith• Wendy Smith
