Skip to content

Instantly share code, notes, and snippets.

View eschneider999's full-sized avatar

eschneider999

View GitHub Profile
@eschneider999
eschneider999 / LoadAbstractItems.vb
Created April 26, 2018 12:02
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")>
@eschneider999
eschneider999 / TestsSimpleCRUD.vb
Last active April 26, 2018 01:21
Symbiotic ORM
Imports FrozenElephant.Symbiotic
<TestClass()>
Public Class TestsSimpleCRUD
Private m_DBTypesFactory As IDatabaseTypesFactory
''' <summary>
@eschneider999
eschneider999 / TestLoadItemById.cs
Created September 25, 2016 20:08
Symbiotic ORM load item by id
public void TestLoadItemById()
{
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();
Person p = loader.ObtainItem<Person>(6000);
}
@eschneider999
eschneider999 / TestDelete.cs
Last active September 25, 2016 20:10
Symbiotic ORM Delete
public void TestDelete()
{
IDatabaseTypesFactory factory = new DatabaseTypesFactorySqlServer();
// Intialize database connection string
factory.ConnectionString = "Data Source=(LocalDB)\\MSSQLLocalDB;AttachDbFilename=D:\\Dev\\FrozenElephant\\SymbioticORM\\SqlDatabase\\SymbioticTestLocal.mdf;Integrated Security=True;Connect Timeout=30";
IObjectWriter writer = factory.CreateObjectWriter();
ErrorItem er = CreateErrorItem("Test 444 " + DateTime.Now.ToString());
@eschneider999
eschneider999 / TestInsertUpdate.cs
Last active March 21, 2018 03:08
Symbiotic ORM Insert Update
public void TestInsertUpdate()
{
IDatabaseTypesFactory factory = new DatabaseTypesFactorySqlServer();
// Intialize database connection string
factory.ConnectionString = "Data Source=(LocalDB)\\MSSQLLocalDB;AttachDbFilename=D:\\Dev\\FrozenElephant\\SymbioticORM\\SqlDatabase\\SymbioticTestLocal.mdf;Integrated Security=True;Connect Timeout=30";
IObjectWriter writer = factory.CreateObjectWriter();
//Should do an insert
@eschneider999
eschneider999 / ParallelLoadHierarchyItems.cs
Last active April 26, 2018 11:57
Symbiotic ORM Parallel Load Hierarchy
public void ParallelLoadHierarchyItems()
{
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", "ParallelLoadHierarchyItems1", typeof(Person));
queries.Add(s1);
@eschneider999
eschneider999 / ParallelLoadItems.cs
Last active November 22, 2016 22:42
Symbiotic ORM Parallel Load
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);
@eschneider999
eschneider999 / TestLoadItems.c
Last active November 22, 2016 22:43
Symbiotic ORM Load Read data
public void TestLoadItems()
{
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<Person> people = loader.ObtainItems<Person>(factory.CreateSqlQuery("Select top 2000 * from People","TestLoadItems"));
if (people.Count == 0)
{
@eschneider999
eschneider999 / TestScalar.cs
Last active November 22, 2016 22:46
Symbiotic ORM ExecuteScalar
public void TestScalar()
{
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();
decimal val = loader.ExecuteScalar<decimal>(factory.CreateSqlQuery("Select count(*) from people","TestScalar"));
}
@eschneider999
eschneider999 / TestExecuteNonQuery.cs
Last active November 22, 2016 22:42
Symbiotic ORM ExecuteNonQuery
public void TestExecuteNonQuery()
{
IDatabaseTypesFactory factory = new DatabaseTypesFactorySqlServer();
factory.ConnectionString = "Data Source=(LocalDB)\\MSSQLLocalDB;AttachDbFilename=D:\\Dev\\FrozenElephant\\SymbioticORM\\SqlDatabase\\SymbioticTestLocal.mdf;Integrated Security=True;Connect Timeout=30";
IObjectWriter writer = factory.CreateObjectWriter();
SqlQuerySimple sql = factory.CreateSqlQuery("update errors set errorinfo= @errorinfo where errorid= @errorid");
sql.CreateAndAddParameter(factory, DbType.String, "errorinfo", "Test: " + DateTime.Now.ToString());
sql.CreateAndAddParameter(factory, DbType.Int32, "errorid", 4);