Last active
November 9, 2016 10:35
-
-
Save smarenich/a604af2dd4ede9c6cd86 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class DatabaseSlotsExample : IPrefetchable | |
{ | |
protected List<string> values = new List<string>(); // store your values here | |
public static List<string> Values | |
{ | |
get | |
{ | |
//Get the values from the slot dynamically. By providing table name, you inform system when it should reset the slot. | |
return PXDatabase.GetSlot<DatabaseSlotsExample>("SlotSuperKey", typeof(YourTable)).values; | |
} | |
} | |
public void Prefetch() | |
{ | |
//read database here | |
foreach(PXDataRecord rec in PXDatabase.SelectMulti<YourTable>( | |
new PXDataField<YourTable.tableField>(), //definition for fields that system should select | |
new PXDataFieldValue<YourTable.tableKey>("Some Condition") //definition for restriction that you need to apply | |
)) | |
{ | |
//populate your collection from the database here | |
values.Add(rec.GetString(0)); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment