Last active
November 22, 2016 22:42
-
-
Save eschneider999/9625a2d5ebc87a5669ef594cff7539d6 to your computer and use it in GitHub Desktop.
Symbiotic ORM Parallel Load
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 void ParallelLoadItems() | |
{ | |
IDatabaseTypesFactory factory = new DatabaseTypesFactorySqlServer(); | |
factory.ConnectionString = "Data Source=(LocalDB)\\MSSQLLocalDB;AttachDbFilename=D:\\Dev\\FrozenElephant\\SymbioticORM\\SqlDatabase\\SymbioticTestLocal.mdf;Integrated Security=True;Connect Timeout=30"; | |
IObjectLoader loader = factory.CreateObjectLoader(); | |
IList<ISqlQuery> queries = new List<ISqlQuery>(); | |
ISqlQuery s1 = factory.CreateSqlQuery("Select top 2000 * from People","ParallelLoadItems:Person", typeof(Person)); | |
queries.Add(s1); | |
ISqlQuery e1 = factory.CreateSqlQuery("Select * from Errors","ParallelLoadItems:ErrorItem", typeof(ErrorItem)); | |
queries.Add(e1); | |
ISqlQuery a1 = factory.CreateSqlQuery("Select * from addresses","ParallelLoadItems:Address", typeof(Address)); | |
queries.Add(a1); | |
ISqlQuery p1 = factory.CreateSqlQuery("Select * from PhoneNumbers","ParallelLoadItems:PhoneNumber", typeof(PhoneNumber)); | |
queries.Add(p1); | |
IList<IList> data = loader.ParallelLoadItems(queries); | |
IList<Address> addresses = (IList<Address>)data[2]; | |
addresses[2].CityName = "Home"; | |
if (data.Count == 0) | |
{ | |
Assert.Fail(); | |
} | |
} |
Also the return collection's results order will be in the same order as queried regardless of completion time of each query. So first collection will be of Person, then ErrorItem, and so on...
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The parameters of "ParallelLoadItems:* are just a debugging aid. The text will be included in any error message to help the developer isolate the problem query.