Skip to content

Instantly share code, notes, and snippets.

@eschneider999
Created April 26, 2018 12:02
Show Gist options
  • Save eschneider999/413905095325366537fa9893ba0ea662 to your computer and use it in GitHub Desktop.
Save eschneider999/413905095325366537fa9893ba0ea662 to your computer and use it in GitHub Desktop.
Symbiotic ORM Load Abstract Items
<TestInitialize()>
Public Sub Initialize()
m_DBTypesFactory = New DatabaseTypesFactorySqlServerWithEncryption
m_DBTypesFactory.ConnectionString = "Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=D:\Dev\FrozenElephant\SymbioticORM\SqlDatabase\SymbioticTestLocal.mdf;Integrated Security=True;Connect Timeout=30;MultipleActiveResultSets=True"
End Sub
''' <summary>
''' Demonstrates loading multiple collections of a concrete type in squence and returning a base type (Non hierarchial).
''' </summary>
<TestCategory("AbstractLoad")>
<TestCategory("Core_SqlServer_VB")>
<TestMethod()>
Public Sub LoadAbstractItems()
Dim loader As IObjectLoader = m_DBTypesFactory.CreateObjectLoader()
Dim queries As IList(Of ISqlQuery) = New List(Of ISqlQuery)()
Dim s1 As ISqlQuery = m_DBTypesFactory.CreateSqlQuery("Select top 100 * from People where role = 1", "SqlServerUnitTest.ParallelLoadItems1", GetType(Person))
queries.Add(s1)
Dim s2 As ISqlQuery = m_DBTypesFactory.CreateSqlQuery("Select top 100 * from People where role = 2", "SqlServerUnitTest.ParallelLoadItems2", GetType(Employee))
queries.Add(s2)
Dim s3 As ISqlQuery = m_DBTypesFactory.CreateSqlQuery("Select top 100 * from People where role = 3", "SqlServerUnitTest.ParallelLoadItems3", GetType(Manager))
queries.Add(s3)
Dim data As IList(Of Person) = loader.LoadAbstractItems(Of Person)(m_DBTypesFactory, queries)
If data.Count = 0 Then
Assert.Fail()
End If
End Sub
@eschneider999
Copy link
Author

Demonstrates loading multiple collections of a concrete types and returned as a collection of abstract types of Person.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment