Sunday, February 26, 2017

Start/Stop/Get details for Windows Services

If you are busy with multiple assignments and cater needs from multiple projects, or may be own a laptop with very little resources, you may want to manipulate windows services active on your laptop by Windows PowerShell.
For example, you may keep handy a .csv targeting one assignment, when you start working on that assignment simply stop other bulky windows services and activate the one you are interested in.

Some helpful commands:


#Get-Service | select-object  status  -unique
#Get-Service | where {$_.status -eq "Running"} 

# get all windows services running:
Get-Service | select Name, CanPauseAndContinue, CanShutdown, CanStop, DisplayName, MachineName, ServiceName, ServiceHandle, Status, ServiceType, StartType, Site, Container, @{Name=’RequiredServices’;Expression={[string]::join(“;”, ($_.RequiredServices.Name))}} ,  @{Name=’DependentServices’;Expression={[string]::join(“;”, ($_.DependentServices.Name))}} ,    @{Name=’ServicesDependedOn’;Expression={[string]::join(“;”, ($_.ServicesDependedOn.Name))}} | Export-Csv c:\gm\servs.csv;

#After analysis of output say, you want to start 3 of them and stop 2, but leave one untouched still be in the csv, create a csv something like:
#(consider the dependencies listed in output above to decide order)
#"Name","Start","Stop"
#"MSSQL$HK2012SQL","TRUE","FALSE"
#"SQLAgent$HK2012SQL","TRUE","FALSE"
#"postgresql-x64-9.5","TRUE","FALSE"
#"wuauserv","FALSE","TRUE"
#"wlidsvc","FALSE","TRUE"
#"RpcSs","FALSE","FALSE"

import-csv "C:\gm\input.csv" | foreach-object { write-host $_.Name; if([bool]::Parse($_.Start)){ Start-Service $_.Name}; if([bool]::Parse($_.Stop)){ Stop-Service $_.Name};}

sample commands at :  bitbucket.org/hemantup/orm/src/HEAD/Scripts/services.txt

But if you are more into security and want control over what is happening over your laptop above mentioned might not be sufficient.
You might need to to deep dive into processes like :

Get-Process | Export-csv "c:\gm\pr.csv"

Friday, February 17, 2017

LLBLGenPro Lite with PostgreSQL and .Net

In this example I used:

LLBLGenPro Lite Version 5.1 (5.1.2) RTM - LITE  Build Date 24-Jan-2017, Licensee: LITE user
Npgsql -Version 3.1.9
CsvHelper -Version 2.16.3
log4net -Version 2.0.7
Visual Studio 2012 with Package Manager Console Host Version 2.8.60318.667

Few tips:

1. Generic part of adapter source code and DB Specific part ( Projects LLBLGenProLite51DBSpecific & LLBLGenProLite51Generic) were created following "LLBLGen Pro Runtime Framework v5.1 Documentation" documentation at llblgen.com/Documentation/5.1/LLBLGen%20Pro%20RTF/index.htm
bitbucket.org/hemantup/orm/src/HEAD/LLBLGenProLite51/LLBLGenProLite51.llblgenproj is the saved project of LLBLGenPro.exe which may be used to regenerate the classes later, if need be.
llblgen.com/Documentation/5.1/LLBLGen%20Pro%20RTF/Tutorials%20And%20Examples/tutorial_createproject.htm

2. The only tweak I had to do to generate the source code (on the top the instructions as mentioned in online help guide "LLBLGen Pro Runtime Framework v5.1 Documentation):
a) Put Npgsql.dll in C:\Program Files (x86)\Solutions Design\LLBLGen Pro v5.1\
b) Some of you might also have to put DbProviderFactories entry under LLBLGenPro_x86.exe.config.
Otherwise you may get error:
Exception details:
=====================
Message: Failed to find or load the registered .Net Framework Data Provider.
Source: System.Data
Stack trace: 
   at System.Data.Common.DbProviderFactories.GetFactory(DataRow providerRow)
   at SD.LLBLGen.Pro.DBDriverCore.DBDriverBase.GetDbProviderFactory()
   at SD.LLBLGen.Pro.DBDriverCore.ConnectionDataBase.get_FactoryName()
   at SD.LLBLGen.Pro.Gui.Controls.WizardPages.MetaDataRetrievalWizard_Step_ConnectionData.<LoadDriverAndConnectionControl>b__16_1()
   at SD.LLBLGen.Pro.Gui.Classes.ApplicationIdleDispatcher.PerformWork()
   at SD.LLBLGen.Pro.Gui.Classes.ApplicationIdleDispatcherSingleton.Application_Idle(Object sender, EventArgs e)
   at System.Windows.Forms.Application.ThreadContext.System.Windows.Forms.UnsafeNativeMethods.IMsoComponent.FDoIdle(Int32 grfidlef)
   at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
   at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
   at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
   at System.Windows.Forms.Form.ShowDialog(IWin32Window owner)
   at SD.LLBLGen.Pro.Gui.Classes.GuiController.PerformAddMetaDataFromDatabaseAction()
   at SD.LLBLGen.Pro.Gui.Controls.ProjectExplorer._mainBarManager_ItemClick(Object sender, ItemClickEventArgs e)
   at DevExpress.XtraBars.BarItem.OnClick(BarItemLink link)
   at DevExpress.XtraBars.BarButtonItem.OnClick(BarItemLink link)
   at DevExpress.XtraBars.BarItemLink.OnLinkClick()
   at DevExpress.XtraBars.BarButtonItemLink.OnLinkAction(BarLinkAction action, Object actionArgs)
   at DevExpress.XtraBars.ViewInfo.BarSelectionInfo.UnPressLink(BarItemLink link)
   at DevExpress.XtraBars.Controls.CustomLinksControl.OnMouseUp(MouseEventArgs e)
   at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at DevExpress.XtraBars.Controls.CustomControl.WndProc(Message& msg)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

Inner exception: <null>

3. In the Console project I created, I had to make DbProviderFactories entry in app.config in addition to installing Npgsql.

For other details, you may refer to comments in bitbucket.org/hemantup/orm/src/HEAD//LLBLGenProLite51/LLBLGenProLite51Console/Program.cs in sample code.



Working sample code is available at bitbucket.org/hemantup/orm/src/HEAD/LLBLGenProLite51/































LLBLGenProLite51Console> Program.cs:

 /*
          -- this is sample db table which I am playing around with:
          -- Table: test_table

          -- DROP TABLE test_table;

          CREATE TABLE test_table
          (
            name text,
            id serial NOT NULL,
            CONSTRAINT test_table_pkey PRIMARY KEY (id)
          )
          WITH (
            OIDS=FALSE
          );
          ALTER TABLE test_table
            OWNER TO postgres;

*/
////Projects LLBLGenProLite51Generic and LLBLGenProLite51DBSpecific are generated using "C:\Program Files (x86)\Solutions Design\LLBLGen Pro v5.1\LLBLGenPro.exe"
////Version 5.1 (5.1.2) RTM - LITE  Build Date 24-Jan-2017, Licensee: LITE user
////available at llblgen.com/Pages/Lite.aspx

////Install-Package Npgsql -Version 3.1.9
/// Install-Package CsvHelper -Version 2.16.3
/// Install-Package log4net -Version 2.0.7
/// Add refrence to SD.LLBLGen.Pro.ORMSupportClasses.dll
/// 
/// while debug, uncomment system.diagnostics section in app.config
/// Also, 
/// SELECT * FROM pg_stat_activity where application_name = 'LLBLGenProLite51Test' and datname = 'test_LLBLGenProLite51' and application_name != 'pgAdmin III - Query Tool' order by query_start desc;

using System;
using System.Collections.Generic;
using System.Configuration;
using System.Diagnostics;
using System.IO;
using CsvHelper;
using CsvHelper.Configuration;
using log4net;
using log4net.Config;
using LLBLGenProLite51.DatabaseSpecific;
using LLBLGenProLite51.EntityClasses;
using LLBLGenProLite51.HelperClasses;

namespace LLBLGenProLite51Console
{
    internal class LLBLGenProLite51Test
    {
        private const int numberofrecords = 5000;
        private const int numberofcycles = 10;
        private const string dateTimeFormat = "yyyy-MM-dd-HH-mm-ss-ffff";

        private static void Main(string[] args)
        {
            XmlConfigurator.Configure();
            var log = LogManager.GetLogger(typeof (LLBLGenProLite51Test));
            log.Info("started.");
            Console.WriteLine("started.");
            var createCollection = new List<CsvRow>();
            var retrieveCollection = new List<CsvRow>();
            var updateCollection = new List<CsvRow>();
            var deleteCollection = new List<CsvRow>();
            var stopWatch = new Stopwatch();

            using (var adapter = new DataAccessAdapter())
            {
                for (var executioncycle = 1; executioncycle <= numberofcycles; executioncycle++)
                {
                    var instRows = new EntityCollection<TestTableEntity>();
                    for (var i = 1; i <= numberofrecords; i++)
                    {
                        var tb = new TestTableEntity {Name = i.ToString()};
                        instRows.Add(tb);
                        // adapter.SaveEntity(tb);// ignore this, just testing another way to insert
                    }
                    var rowCreate = new CsvRow();
                    log.InfoFormat("starting create. executioncycle: {0}", executioncycle);
                    Console.WriteLine("starting create. executioncycle: {0}", executioncycle);
                    rowCreate.Start = DateTime.Now.ToString(dateTimeFormat);
                    stopWatch.Start();
                    adapter.SaveEntityCollection(instRows);
                    //for each row:
                    //SELECT currval('"public"."test_table_id_seq"')
                    //INSERT INTO "public"."test_table" ("id", "name") VALUES (nextval('"public"."test_table_id_seq"'), :p2)
                    stopWatch.Stop();
                    rowCreate.End = DateTime.Now.ToString(dateTimeFormat);
                    log.InfoFormat("finished creating. executioncycle: {0}", executioncycle);
                    Console.WriteLine("finished creating. executioncycle: {0}", executioncycle);
                    rowCreate.TimeTaken = stopWatch.Elapsed.TotalMilliseconds.ToString();
                    stopWatch.Reset();
                    createCollection.Add(rowCreate);


                    /* ignore this part, just testing another way to retrive
                //var metaData = new LinqMetaData(adapter);
                //var q = from c in metaData.TestTable
                //        select c;
                //var output = q.ToList();                   
                 */


                    var allRows = new EntityCollection<TestTableEntity>();
                    var rowRetrieve = new CsvRow();
                    log.InfoFormat("starting retrieve. executioncycle: {0}", executioncycle);
                    Console.WriteLine("starting retrieve. executioncycle: {0}", executioncycle);
                    rowRetrieve.Start = DateTime.Now.ToString(dateTimeFormat);
                    stopWatch.Start();
                    adapter.FetchEntityCollection(allRows, null);
                    //SELECT "public"."test_table"."id" AS "Id", "public"."test_table"."name" AS "Name" FROM "public"."test_table"  
                    stopWatch.Stop();
                    rowRetrieve.End = DateTime.Now.ToString(dateTimeFormat);
                    log.InfoFormat("finished retrieve. executioncycle: {0}", executioncycle);
                    Console.WriteLine("finished retrieve. executioncycle: {0}", executioncycle);
                    rowRetrieve.TimeTaken = stopWatch.Elapsed.TotalMilliseconds.ToString();
                    stopWatch.Reset();
                    retrieveCollection.Add(rowRetrieve);


                    foreach (var item in allRows)
                    {
                        item.Name = string.Format("{0}_{1}", item.Name, DateTime.Now.ToString(dateTimeFormat));
                    }
                    var rowUpdate = new CsvRow();
                    log.InfoFormat("starting update. executioncycle: {0}", executioncycle);
                    Console.WriteLine("starting update. executioncycle: {0}", executioncycle);
                    rowUpdate.Start = DateTime.Now.ToString(dateTimeFormat);
                    stopWatch.Start();
                    adapter.SaveEntityCollection(allRows);
                    //for each row
                    //UPDATE "public"."test_table" SET "name"=:p1 WHERE ( "public"."test_table"."id" = :p2)
                    stopWatch.Stop();
                    rowUpdate.End = DateTime.Now.ToString(dateTimeFormat);
                    log.InfoFormat("finished update. executioncycle: {0}", executioncycle);
                    Console.WriteLine("finished update. executioncycle: {0}", executioncycle);
                    rowUpdate.TimeTaken = stopWatch.Elapsed.TotalMilliseconds.ToString();
                    stopWatch.Reset();
                    updateCollection.Add(rowUpdate);


                    var rowDelete = new CsvRow();
                    log.InfoFormat("starting delete. executioncycle: {0}", executioncycle);
                    Console.WriteLine("starting delete. executioncycle: {0}", executioncycle);
                    rowDelete.Start = DateTime.Now.ToString(dateTimeFormat);
                    stopWatch.Start();
                    adapter.DeleteEntityCollection(allRows);
                    //for each row 
                    //DELETE FROM "public"."test_table" WHERE ( "public"."test_table"."id" = :p1)
                    stopWatch.Stop();
                    rowDelete.End = DateTime.Now.ToString(dateTimeFormat);
                    log.InfoFormat("finished delete. executioncycle: {0}", executioncycle);
                    Console.WriteLine("finished delete. executioncycle: {0}", executioncycle);
                    rowDelete.TimeTaken = stopWatch.Elapsed.TotalMilliseconds.ToString();
                    stopWatch.Reset();
                    deleteCollection.Add(rowDelete);


                    adapter.ExecuteSQL("ALTER SEQUENCE test_table_id_seq RESTART WITH 1");
                }
            }
            CreateCSVs(createCollection, retrieveCollection, updateCollection, deleteCollection);

            Console.WriteLine("Done");
            Console.ReadLine();
        }

        private static void CreateCSVs(List<CsvRow> createCollection, List<CsvRow> retrieveCollection,
            List<CsvRow> updateCollection,
            List<CsvRow> deleteCollection)
        {
            using (var sw = new StreamWriter(ConfigurationManager.AppSettings["csvLocationcreate"]))
            {
                var csv = new CsvWriter(sw);
                csv.Configuration.RegisterClassMap<CsvRowMap>();
                csv.WriteRecords(createCollection);
            }
            using (var sw = new StreamWriter(ConfigurationManager.AppSettings["csvLocationretrieve"]))
            {
                var csv = new CsvWriter(sw);

                csv.WriteRecords(retrieveCollection);
            }
            using (var sw = new StreamWriter(ConfigurationManager.AppSettings["csvLocationupdate"]))
            {
                var csv = new CsvWriter(sw);

                csv.WriteRecords(updateCollection);
            }
            using (var sw = new StreamWriter(ConfigurationManager.AppSettings["csvLocationdelete"]))
            {
                var csv = new CsvWriter(sw);

                csv.WriteRecords(deleteCollection);
            }
        }
    }

    public class CsvRow
    {
        public string Start { get; set; }
        public string End { get; set; }
        public string TimeTaken { get; set; }
    }


    public sealed class CsvRowMap : CsvClassMap<CsvRow>
    {
        public CsvRowMap()
        {
            AutoMap();
        }
    }
}


LLBLGenProLite51Console> packages.config:
<?xml version="1.0" encoding="utf-8"?>
<packages>
  <package id="CsvHelper" version="2.16.3.0" targetFramework="net45" />
  <package id="log4net" version="2.0.7" targetFramework="net45" />
  <package id="Npgsql" version="3.1.0" targetFramework="net45" />
</packages>


LLBLGenProLite51Console>App.config:
<?xml version="1.0" encoding="utf-8"?>

<configuration>
  <configSections>
    <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
  </configSections>

  <log4net>
    <appender name="FileAppender" type="log4net.Appender.RollingFileAppender">
      <param name="File" value="c:\logs\LLBLGenProLite51_test.log" />
      <param name="AppendToFile" value="true" />
      <param name="RollingStyle" value="Date" />
      <param name="DatePattern" value="yyyyMMdd-HHmm" />
      <param name="PreserveLogFileNameExtension" value="true" />
      <layout type="log4net.Layout.PatternLayout">
        <param name="Header" type="log4net.Util.PatternString" value="[LOG STARTED]%newline" />
        <param name="Footer" type="log4net.Util.PatternString" value="[LOG ENDED]%newline" />
        <param name="ConversionPattern" value="%d [%t] %-5p %c %m%n" />
      </layout>
    </appender>
    <appender name="TraceAppender" type="log4net.Appender.TraceAppender, log4net">
      <immediateFlush value="true" />
      <layout type="log4net.Layout.PatternLayout,log4net">
        <conversionPattern value="%date [%thread] %-5level %logger - %message%newline" />
      </layout>
    </appender>
    <appender name="ConsoleAppender" type="log4net.Appender.ConsoleAppender">
      <layout type="log4net.Layout.PatternLayout">
        <conversionPattern value="%date [%thread] %-5level %logger [%property{NDC}] - %message%newline" />
      </layout>
    </appender>
    <root>
      <level value="INFO" />
      <appender-ref ref="FileAppender" />
      <appender-ref ref="TraceAppender" />
      <appender-ref ref="ConsoleAppender" />
    </root>
  </log4net>
  <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
  </startup>
  <connectionStrings>
    <add name="ConnectionString.PostgreSql (Npgsql)"
         connectionString="Database=test_LLBLGenProLite51;Server=localhost;Port=5432;User Id=postgres;Password=removed; ApplicationName=LLBLGenProLite51Test;"
         providerName="Npgsql" />
  </connectionStrings>

  <system.data>
    <DbProviderFactories>
      <remove invariant="Npgsql" />
      <add name="Npgsql Data Provider" invariant="Npgsql" description=".Net Data Provider for PostgreSQL"
           type="Npgsql.NpgsqlFactory, Npgsql, Culture=neutral, PublicKeyToken=5d8b90d52f46fda7" support="FF" />
    </DbProviderFactories>
  </system.data>
  <system.diagnostics>
    <switches>
      <add name="PostgreSqlDQE" value="4" />
      <add name="ORMQueryExecution" value="4" />
    </switches>
  </system.diagnostics>
  <appSettings>
    <add key="csvLocationcreate" value="c:\logs\LLBLGenProLite51_test_create.csv" />
    <add key="csvLocationretrieve" value="c:\logs\LLBLGenProLite51_test_retrieve.csv" />
    <add key="csvLocationupdate" value="c:\logs\LLBLGenProLite51_test_update.csv" />
    <add key="csvLocationdelete" value="c:\logs\LLBLGenProLite51_test_delete.csv" />

  </appSettings>
</configuration>







Thursday, February 16, 2017

Symbiotic_Data_Provider_PostgreSql_x64 with PostgreSQL and .Net

In this example I used:
Symbiotic_x64 -Version 4.0.4.1
Symbiotic_Data_Provider_PostgreSql_x64 -Version 2.0.0
Npgsql -Version 3.1.9
CsvHelper -Version 2.16.3
log4net -Version 2.0.7
test_table.cs using Symbiotic Code Generator

Working sample code is available at bitbucket.org/hemantup/orm/src/HEAD/SymbioticDataProviderPostgreSql2/




















Program.cs:
/*
          -- this is sample db table which I am playing around with:
          -- Table: test_table

          -- DROP TABLE test_table;

          CREATE TABLE test_table
          (
            name text,
            id serial NOT NULL,
            CONSTRAINT test_table_pkey PRIMARY KEY (id)
          )
          WITH (
            OIDS=FALSE
          );
          ALTER TABLE test_table
            OWNER TO postgres;

*/
//Install-Package Symbiotic_x64 -Version 4.0.4.1
//Install-Package Symbiotic_Data_Provider_PostgreSql_x64 -Version 2.0.0
//Install-Package Npgsql -Version 3.1.9

//test_table.cs from www.frozenelephant.com/symbiotic/publish.htm  - the Symbiotic Code Generator
//while creating test_table.cs-ORM Data layer using the tool, if you get error like  Could not load file or assembly 'Npgsql....
//you may put the respective version of Npgsql  in the same folder as exe of the Symbiotic Code Generator. Location of exe may be found from Task manager when utility is running. 


//Install-Package CsvHelper -Version 2.16.3
//Install-Package log4net -Version 2.0.7

// set platform target for your project to x64 for this test.

//Uninstall-Package log4net


using System;
using System.Collections.Generic;
using System.Configuration;
using System.Diagnostics;
using System.IO;
using CsvHelper;
using CsvHelper.Configuration;
using FrozenElephant.Symbiotic;
using Npgsql;
//using log4net;
//using log4net.Config;

namespace SymbioticDataProviderPostgreSql2
{
    internal class SymbioticDataProviderPostgreSql2Test
    {
        private const int numberofrecords = 5000;
        private const int numberofcycles = 10;
        private const string dateTimeFormat = "yyyy-MM-dd-HH-mm-ss-ffff";

        private static void Main(string[] args)
        {
            //XmlConfigurator.Configure();
            //var log = LogManager.GetLogger(typeof (SymbioticDataProviderPostgreSql2Test));
            //log.Info("started.");
            Console.WriteLine("started.");
            var createCollection = new List<CsvRow>();
            var retrieveCollection = new List<CsvRow>();
            var updateCollection = new List<CsvRow>();
            var deleteCollection = new List<CsvRow>();
            var stopWatch = new Stopwatch();
            //SELECT * FROM pg_stat_activity where application_name = 'SymbioticDataProviderPostgreSql2Test' and datname = 'test_SymbioticDataProviderPostgreSql2' and application_name != 'pgAdmin III - Query Tool' order by query_start desc;

            var m_DbTypesFactory = new DatabaseTypesFactoryPostgreSql();
            m_DbTypesFactory.ConnectionString =
                ConfigurationManager.ConnectionStrings["PostgreeDbContext"].ConnectionString;
            var writer = m_DbTypesFactory.CreateObjectWriter();
            var loader = m_DbTypesFactory.CreateObjectLoader();

            for (var executioncycle = 1; executioncycle <= numberofcycles; executioncycle++)
            {
                var instRows = new List<test_table>();
                for (var i = 1; i <= numberofrecords; i++)
                {
                    var tb = new test_table {name = i.ToString()};

                    instRows.Add(tb);
                }
                var rowCreate = new CsvRow();
                //log.InfoFormat("starting create. executioncycle: {0}", executioncycle);
                Console.WriteLine("starting create. executioncycle: {0}", executioncycle);
                rowCreate.Start = DateTime.Now.ToString(dateTimeFormat);
                stopWatch.Start();
                writer.Create(m_DbTypesFactory, instRows, false);
                stopWatch.Stop();
                rowCreate.End = DateTime.Now.ToString(dateTimeFormat);
                //log.InfoFormat("finished creating. executioncycle: {0}", executioncycle);
                Console.WriteLine("finished creating. executioncycle: {0}", executioncycle);
                rowCreate.TimeTaken = stopWatch.Elapsed.TotalMilliseconds.ToString();
                stopWatch.Reset();
                createCollection.Add(rowCreate);
                //var instRows = new List<test_table>();
                //for (var i = 1; i <= numberofrecords; i++)
                //{
                //    var tb = new test_table {name = i.ToString()};

                //    instRows.Add(tb);
                //}
                //  writer.Create(m_DBTypesFactory, instRows,true);
                /*
            System.NotSupportedException was unhandled
  HResult=-2146233067
  Message=Sql server support only!
  Source=FrozenElephant.Symbiotic
  StackTrace:
       at FrozenElephant.Symbiotic.ObjectWriter.Create[T](IDatabaseTypesFactory factory, IList`1 values, Boolean useBulk)
       at SymbioticDataProviderPostgreSql2.SymbioticDataProviderPostgreSql2Test.Main(String[] args) in c:\891\SymbioticDataProviderPostgreSql2\Program.cs:line 49
       at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException: 
            */


                var rowRetrieve = new CsvRow();
                // log.InfoFormat("starting retrieve. executioncycle: {0}", executioncycle);
                Console.WriteLine("starting retrieve. executioncycle: {0}", executioncycle);
                rowRetrieve.Start = DateTime.Now.ToString(dateTimeFormat);
                stopWatch.Start();
                var allRows = loader.ObtainItems<test_table>(m_DbTypesFactory,
                    new SqlQuerySimple("SELECT * FROM public.test_table"));
                stopWatch.Stop();
                rowRetrieve.End = DateTime.Now.ToString(dateTimeFormat);
                //log.InfoFormat("finished retrieve. executioncycle: {0}", executioncycle);
                Console.WriteLine("finished retrieve. executioncycle: {0}", executioncycle);
                rowRetrieve.TimeTaken = stopWatch.Elapsed.TotalMilliseconds.ToString();
                stopWatch.Reset();
                retrieveCollection.Add(rowRetrieve);


                var rowUpdate = new CsvRow();
                //log.InfoFormat("starting update. executioncycle: {0}", executioncycle);
                Console.WriteLine("starting update. executioncycle: {0}", executioncycle);
                rowUpdate.Start = DateTime.Now.ToString(dateTimeFormat);
                foreach (var item in allRows)
                {
                    item.name = string.Format("{0}_{1}", item.name, DateTime.Now.ToString(dateTimeFormat));
                    stopWatch.Start();
                    writer.Update(m_DbTypesFactory, item);
                    stopWatch.Stop();
                }
                rowUpdate.End = DateTime.Now.ToString(dateTimeFormat);
                //log.InfoFormat("finished update. executioncycle: {0}", executioncycle);
                Console.WriteLine("finished update. executioncycle: {0}", executioncycle);
                rowUpdate.TimeTaken = stopWatch.Elapsed.TotalMilliseconds.ToString();
                stopWatch.Reset();
                updateCollection.Add(rowUpdate);


                var rowDelete = new CsvRow();
                //log.InfoFormat("starting delete. executioncycle: {0}", executioncycle);
                Console.WriteLine("starting delete. executioncycle: {0}", executioncycle);
                rowDelete.Start = DateTime.Now.ToString(dateTimeFormat);
                foreach (var item in allRows)
                {
                    stopWatch.Start();
                    writer.Delete(m_DbTypesFactory, item);
                    stopWatch.Stop();
                }
                rowDelete.End = DateTime.Now.ToString(dateTimeFormat);
                // log.InfoFormat("finished delete. executioncycle: {0}", executioncycle);
                Console.WriteLine("finished delete. executioncycle: {0}", executioncycle);
                rowDelete.TimeTaken = stopWatch.Elapsed.TotalMilliseconds.ToString();
                stopWatch.Reset();
                deleteCollection.Add(rowDelete);

                /*
                writer.ExecuteNonQuery(m_DbTypesFactory,
                    new SqlQuerySimple("ALTER SEQUENCE test_table_id_seq RESTART WITH 1"));
                 
                FrozenElephant.Symbiotic.SqlInjectionValidationException was unhandled
  HResult=-2146233088
  Message=Found alter commands in the sql statement.
  Source=FrozenElephant.Symbiotic
  StackTrace:
       at FrozenElephant.Symbiotic.SqlQuerySimple.ValidateNoAlter()
       at FrozenElephant.Symbiotic.SqlQuerySimple.ValidateSql()
       at FrozenElephant.Symbiotic.SqlQuerySimple.ObtainSql()
       at FrozenElephant.Symbiotic.ObjectWriter.ExecuteNonQuery(IDatabaseTypesFactory factory, ISqlQuery sql)
       at SymbioticDataProviderPostgreSql2.SymbioticDataProviderPostgreSql2Test.Main(String[] args) in c:\891\SymbioticDataProviderPostgreSql2\Program.cs:line 175
       at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException: 
                */

             //   ResetSequence();

                //fixed Found alter commands in the sql statement. by ShouldPerformValidation. No need for ResetSequence by direct Npgsql now
                var alterSeqQ = new SqlQuerySimple("ALTER SEQUENCE test_table_id_seq RESTART WITH 1");
                alterSeqQ.ShouldPerformValidation = false;
                writer.ExecuteNonQuery(m_DbTypesFactory, alterSeqQ);
            }
            CreateCSVs(createCollection, retrieveCollection, updateCollection, deleteCollection);

            Console.WriteLine("Done");
           // Console.ReadLine();
        }

        //private static void ResetSequence()
        //{
        //    var cString = ConfigurationManager.ConnectionStrings["PostgreeDbContext"].ConnectionString;
        //    var conn = new NpgsqlConnection(cString);
        //    conn.Open();
        //    new NpgsqlCommand("ALTER SEQUENCE test_table_id_seq RESTART WITH 1;", conn).ExecuteNonQuery();
        //    conn.Close();
        //}

        private static void CreateCSVs(List<CsvRow> createCollection, List<CsvRow> retrieveCollection,
            List<CsvRow> updateCollection,
            List<CsvRow> deleteCollection)
        {
            using (var sw = new StreamWriter(ConfigurationManager.AppSettings["csvLocationcreate"]))
            {
                var csv = new CsvWriter(sw);
                csv.Configuration.RegisterClassMap<CsvRowMap>();
                csv.WriteRecords(createCollection);
            }
            using (var sw = new StreamWriter(ConfigurationManager.AppSettings["csvLocationretrieve"]))
            {
                var csv = new CsvWriter(sw);

                csv.WriteRecords(retrieveCollection);
            }
            using (var sw = new StreamWriter(ConfigurationManager.AppSettings["csvLocationupdate"]))
            {
                var csv = new CsvWriter(sw);

                csv.WriteRecords(updateCollection);
            }
            using (var sw = new StreamWriter(ConfigurationManager.AppSettings["csvLocationdelete"]))
            {
                var csv = new CsvWriter(sw);

                csv.WriteRecords(deleteCollection);
            }
        }
    }

    public class CsvRow
    {
        public string Start { get; set; }
        public string End { get; set; }
        public string TimeTaken { get; set; }
    }


    public sealed class CsvRowMap : CsvClassMap<CsvRow>
    {
        public CsvRowMap()
        {
            AutoMap();
        }
    }
}




test_table.cs:


namespace SymbioticDataProviderPostgreSql2 {

using FrozenElephant.Symbiotic;

using System;
using System.Diagnostics;
[Serializable()]
[DatabaseTable("test_table")]
public  class test_table 
{

    #region Private Memebers
    private string m_name;
    private int m_id;

    #endregion
    [DatabaseColumnAttribute("name", isPrimaryKey: false, isIdentityColumn: false)]
/// <summary>
/// Gets or sets name.
/// </summary>
    public string name {
   get { return m_name; }
   set { m_name = value; }
    }

    [DatabaseColumnAttribute("id", isPrimaryKey: true, isIdentityColumn: true)]
/// <summary>
/// Gets or sets id.
/// </summary>
    public int id {
   get { return m_id; }
   set { m_id = value; }
    }



}
}



packages.config:
<?xml version="1.0" encoding="utf-8"?>
<packages>
  <package id="CsvHelper" version="2.16.3.0" targetFramework="net45" />
  <package id="Npgsql" version="3.1.9" targetFramework="net45" />
  <package id="Symbiotic_Data_Provider_PostgreSql_x64" version="2.0.0.0" targetFramework="net45" />
  <package id="Symbiotic_x64" version="4.0.4.1" targetFramework="net45" />
</packages>


App.config:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<!--<configSections>
    <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
  </configSections>

  <log4net>
    <appender name="FileAppender" type="log4net.Appender.RollingFileAppender">
      <param name="File" value="c:\logs\SymbioticDataProviderPostgreSql_test.log" />
      <param name="AppendToFile" value="true" />
      <param name="RollingStyle" value="Date" />
      <param name="DatePattern" value="yyyyMMdd-HHmm" />
      <param name="PreserveLogFileNameExtension" value="true" />
      <layout type="log4net.Layout.PatternLayout">
        <param name="Header" type="log4net.Util.PatternString" value="[LOG STARTED]%newline" />
        <param name="Footer" type="log4net.Util.PatternString" value="[LOG ENDED]%newline" />
        <param name="ConversionPattern" value="%d [%t] %-5p %c %m%n" />
      </layout>
    </appender>
    <appender name="TraceAppender" type="log4net.Appender.TraceAppender, log4net">
      <immediateFlush value="true" />
      <layout type="log4net.Layout.PatternLayout,log4net">
        <conversionPattern value="%date [%thread] %-5level %logger - %message%newline" />
      </layout>
    </appender>
    <appender name="ConsoleAppender" type="log4net.Appender.ConsoleAppender">
      <layout type="log4net.Layout.PatternLayout">
        <conversionPattern value="%date [%thread] %-5level %logger [%property{NDC}] - %message%newline" />
      </layout>
    </appender>
    <root>
      <level value="INFO" />
      <appender-ref ref="FileAppender" />
      <appender-ref ref="TraceAppender" />
      <appender-ref ref="ConsoleAppender" />
    </root>
  </log4net>-->
    <startup> 
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
    </startup>
  <connectionStrings>
    <add name="PostgreeDbContext" connectionString="Server=localhost;Port=5432;Database=test_SymbioticDataProviderPostgreSql2;User Id=postgres;Password=removed; ApplicationName=SymbioticDataProviderPostgreSql2Test;" providerName="Npgsql" />
  </connectionStrings>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="Npgsql" publicKeyToken="5d8b90d52f46fda7" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-3.1.9.0" newVersion="3.1.9.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
  <appSettings>
    <add key="csvLocationcreate" value="c:\logs\SymbioticDataProviderPostgreSql_test_create.csv" />
    <add key="csvLocationretrieve" value="c:\logs\SymbioticDataProviderPostgreSql_test_retrieve.csv" />
    <add key="csvLocationupdate" value="c:\logs\SymbioticDataProviderPostgreSql_test_update.csv" />
    <add key="csvLocationdelete" value="c:\logs\SymbioticDataProviderPostgreSql_test_delete.csv" />

  </appSettings>
</configuration>

Wednesday, February 15, 2017

Uni.ORM with PostgreSQL and .Net

Uni.ORM with PostgreSQL and .Net

In this example I used:

Npgsql -Version 3.1.9

CsvHelper -Version 2.16.3

log4net -Version 2.0.7

Uni.Extensions -Version 1.1.8 ( see comments in bitbucket.org/hemantup/orm/src/HEAD/UniORM144/Program.cs, if you use Uni.Extensions 1.1.9, along with Uni.ORM 1.4.4, it will give error Field not found: 'Uni.Extensions.UniExtensions.stringType'.)

Uni.ORM -Version 1.4.4

Working sample code is available at bitbucket.org/hemantup/orm/src/HEAD/UniORM144/



Program.cs:

/*
          -- this is sample db table which you are playing around with:
          -- Table: test_table

          -- DROP TABLE test_table;

          CREATE TABLE test_table
          (
            name text,
            id serial NOT NULL,
            CONSTRAINT test_table_pkey PRIMARY KEY (id)
          )
          WITH (
            OIDS=FALSE
          );
          ALTER TABLE test_table
            OWNER TO postgres;

          */
//Install-Package Uni.Extensions -Version 1.1.9 - this I had to update later , see comments in main
//Install-Package Uni.ORM -Version 1.4.4- this I had to update later , see comments in main
//Install-Package Npgsql -Version 3.1.9
//SELECT * FROM pg_stat_activity where application_name = 'UniORM144Test' and datname = 'test_UniORM144' and application_name != 'pgAdmin III - Query Tool' order by query_start desc;
// Install-Package CsvHelper -Version 2.16.3
// Install-Package log4net -Version 2.0.7
//uninstall-package log4net
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Diagnostics;
using System.IO;
using System.Linq;
using CsvHelper;
using CsvHelper.Configuration;
//using log4net;
//using log4net.Config;
using Npgsql;
using Uni.Orm;

namespace UniORM144
{
    internal class UniORM144Test
    {
        private const int numberofrecords = 5000;
        private const int numberofcycles = 10;
        private const string dateTimeFormat = "yyyy-MM-dd-HH-mm-ss-ffff";

        private static void Main(string[] args)
        {
            //XmlConfigurator.Configure();
            //var log = LogManager.GetLogger(typeof (UniORM144Test));
            //log.Info("started.");
            Console.WriteLine("started.");
            var createCollection = new List<CsvRow>();
            var retrieveCollection = new List<CsvRow>();
            var updateCollection = new List<CsvRow>();
            var deleteCollection = new List<CsvRow>();
            var stopWatch = new Stopwatch();
            var postgresql = new UniOrm("PostgreeDbContext", NpgsqlFactory.Instance);


            //  var result = postgresql.dyno.Query(Schema: "public", Table: "test_table");
            /* I got below mentioned error at var result = postgresql.dyno.Query(Schema: "public", Table: "test_table");
          System.MissingFieldException was unhandled
HResult=-2146233071
Message=Field not found: 'Uni.Extensions.UniExtensions.stringType'.
Source=Uni.Orm
StackTrace:
     at Uni.Orm.UniOrm.TryInvokeMember(InvokeMemberBinder binder, Object[] args, Object& result)
     at CallSite.Target(Closure , CallSite , Object , String , String )
     at System.Dynamic.UpdateDelegates.UpdateAndExecute3[T0,T1,T2,TRet](CallSite site, T0 arg0, T1 arg1, T2 arg2)
     at UniORM144.UniORM144Test.Main(String[] args) in c:\891\UniORM144\Program.cs:line 35
     at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
     at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
     at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
     at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
     at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
     at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
     at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
     at System.Threading.ThreadHelper.ThreadStart()
InnerException: 
             * 
             * Resolution:
             * uninstall-package Uni.ORM
             * uninstall-package Uni.Extensions
             * Install-Package Uni.Extensions -Version 1.1.8
             *  install-Package Uni.ORM -Version 1.4.4
             *  so, 1.1.9 version of extensions was the source of issue
           */

            /*
          //generating   poco
            var result1 = postgresql.dyno.Query(Table: "test_table", Limit: 1);

            var anonymousObj = new UniAnonymousObject();

            var tblType = anonymousObj.GetDynamicType(result1, "test_table");

            string tblPoco = anonymousObj.GetPoco(result1, "test_table");
             */


            for (var executioncycle = 1; executioncycle <= numberofcycles; executioncycle++)
            {
                var insertRows = new List<test_table>();
                for (var i = 1; i <= numberofrecords; i++)
                {
                    var tb = new test_table {name = i.ToString()};
                    insertRows.Add(tb);
                }
                var insertRowsAr = insertRows.ToArray();
                var rowCreate = new CsvRow();
               // log.InfoFormat("starting create. executioncycle: {0}", executioncycle);
                Console.WriteLine("starting create. executioncycle: {0}", executioncycle);
                rowCreate.Start = DateTime.Now.ToString(dateTimeFormat);
                stopWatch.Start();
                var insertResult = postgresql.dyno.Insert(
                    Table: "test_table",
                    PKField: "id",
                    Args: insertRowsAr
                    );
                stopWatch.Stop();
                rowCreate.End = DateTime.Now.ToString(dateTimeFormat);
              //  log.InfoFormat("finished creating. executioncycle: {0}", executioncycle);
                Console.WriteLine("finished creating. executioncycle: {0}", executioncycle);
                rowCreate.TimeTaken = stopWatch.Elapsed.TotalMilliseconds.ToString();
                stopWatch.Reset();
                createCollection.Add(rowCreate);





                var rowRetrieve = new CsvRow();
              //  log.InfoFormat("starting retrieve. executioncycle: {0}", executioncycle);
                Console.WriteLine("starting retrieve. executioncycle: {0}", executioncycle);
                rowRetrieve.Start = DateTime.Now.ToString(dateTimeFormat);
                stopWatch.Start();
                IEnumerable<test_table> result = postgresql.dyno.Query<test_table>(Schema: "public", Table: "test_table");
                stopWatch.Stop();
                rowRetrieve.End = DateTime.Now.ToString(dateTimeFormat);
              //  log.InfoFormat("finished retrieve. executioncycle: {0}", executioncycle);
                Console.WriteLine("finished retrieve. executioncycle: {0}", executioncycle);
                rowRetrieve.TimeTaken = stopWatch.Elapsed.TotalMilliseconds.ToString();
                stopWatch.Reset();
                retrieveCollection.Add(rowRetrieve);








                var allRows = result.ToList();
                foreach (var item in allRows)
                {
                    item.name = string.Format("{0}_{1}", item.name, DateTime.Now.ToString(dateTimeFormat));
                }
                var allRowsAr = allRows.ToArray();
                var rowUpdate = new CsvRow();
               // log.InfoFormat("starting update. executioncycle: {0}", executioncycle);
                Console.WriteLine("starting update. executioncycle: {0}", executioncycle);
                rowUpdate.Start = DateTime.Now.ToString(dateTimeFormat);
                stopWatch.Start();
                var bulkUpdateResult = postgresql.dyno.Update(
                    Table: "test_table",
                    Columns: "name",
                    Args: allRowsAr
                    );
                stopWatch.Stop();
                rowUpdate.End = DateTime.Now.ToString(dateTimeFormat);
               // log.InfoFormat("finished update. executioncycle: {0}", executioncycle);
                Console.WriteLine("finished update. executioncycle: {0}", executioncycle);
                rowUpdate.TimeTaken = stopWatch.Elapsed.TotalMilliseconds.ToString();
                stopWatch.Reset();
                updateCollection.Add(rowUpdate);







                // var allRowsIdAr = allRows.Select(x => x.id).ToArray(); int[] won't work
                var allRowsIdAr = allRows.Select(x => x.id as object).ToArray();
                var rowDelete = new CsvRow();
              //  log.InfoFormat("starting delete. executioncycle: {0}", executioncycle);
                Console.WriteLine("starting delete. executioncycle: {0}", executioncycle);
                rowDelete.Start = DateTime.Now.ToString(dateTimeFormat);
                stopWatch.Start();
                var deleteResult = postgresql.dyno.Delete(Table: "test_table", PKField: "id", Args: allRowsIdAr);
                stopWatch.Stop();
                rowDelete.End = DateTime.Now.ToString(dateTimeFormat);
                //log.InfoFormat("finished delete. executioncycle: {0}", executioncycle);
                Console.WriteLine("finished delete. executioncycle: {0}", executioncycle);
                rowDelete.TimeTaken = stopWatch.Elapsed.TotalMilliseconds.ToString();
                stopWatch.Reset();
                deleteCollection.Add(rowDelete);





                postgresql.ExecuteNonQuery(CommandType.Text, "public",
                    commandText: "ALTER SEQUENCE test_table_id_seq RESTART WITH 1", args: null);
            }
            CreateCSVs(createCollection, retrieveCollection, updateCollection, deleteCollection);

            Console.WriteLine("Done");
            //Console.ReadLine();
        }

        private static void CreateCSVs(List<CsvRow> createCollection, List<CsvRow> retrieveCollection,
            List<CsvRow> updateCollection,
            List<CsvRow> deleteCollection)
        {
            using (var sw = new StreamWriter(ConfigurationManager.AppSettings["csvLocationcreate"]))
            {
                var csv = new CsvWriter(sw);
                csv.Configuration.RegisterClassMap<CsvRowMap>();
                csv.WriteRecords(createCollection);
            }
            using (var sw = new StreamWriter(ConfigurationManager.AppSettings["csvLocationretrieve"]))
            {
                var csv = new CsvWriter(sw);

                csv.WriteRecords(retrieveCollection);
            }
            using (var sw = new StreamWriter(ConfigurationManager.AppSettings["csvLocationupdate"]))
            {
                var csv = new CsvWriter(sw);

                csv.WriteRecords(updateCollection);
            }
            using (var sw = new StreamWriter(ConfigurationManager.AppSettings["csvLocationdelete"]))
            {
                var csv = new CsvWriter(sw);

                csv.WriteRecords(deleteCollection);
            }
        }
    }

    public class test_table
    {
        public string name { get; set; }

        public int id { get; set; }
    }

    public class CsvRow
    {
        public string Start { get; set; }
        public string End { get; set; }
        public string TimeTaken { get; set; }
    }


    public sealed class CsvRowMap : CsvClassMap<CsvRow>
    {
        public CsvRowMap()
        {
            AutoMap();
        }
    }
}


packages.config:
<?xml version="1.0" encoding="utf-8"?>
<packages>
  <package id="CsvHelper" version="2.16.3.0" targetFramework="net45" />
  <package id="Npgsql" version="3.1.9" targetFramework="net45" />
  <package id="Uni.Extensions" version="1.1.8" targetFramework="net45" />
  <package id="Uni.ORM" version="1.4.4" targetFramework="net45" />
</packages>

App.config:
<?xml version="1.0" encoding="utf-8"?>

<configuration>
  <!--<configSections>
    <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
  </configSections>
  <log4net>
    <appender name="FileAppender" type="log4net.Appender.RollingFileAppender">
      <param name="File" value="c:\logs\UniORM144_test.log" />
      <param name="AppendToFile" value="true" />
      <param name="RollingStyle" value="Date" />
      <param name="DatePattern" value="yyyyMMdd-HHmm" />
      <param name="PreserveLogFileNameExtension" value="true" />
      <layout type="log4net.Layout.PatternLayout">
        <param name="Header" type="log4net.Util.PatternString" value="[LOG STARTED]%newline" />
        <param name="Footer" type="log4net.Util.PatternString" value="[LOG ENDED]%newline" />
        <param name="ConversionPattern" value="%d [%t] %-5p %c %m%n" />
      </layout>
    </appender>
    <appender name="TraceAppender" type="log4net.Appender.TraceAppender, log4net">
      <immediateFlush value="true" />
      <layout type="log4net.Layout.PatternLayout,log4net">
        <conversionPattern value="%date [%thread] %-5level %logger - %message%newline" />
      </layout>
    </appender>
    <appender name="ConsoleAppender" type="log4net.Appender.ConsoleAppender">
      <layout type="log4net.Layout.PatternLayout">
        <conversionPattern value="%date [%thread] %-5level %logger [%property{NDC}] - %message%newline" />
      </layout>
    </appender>
    <root>
      <level value="INFO" />
      <appender-ref ref="FileAppender" />
      <appender-ref ref="TraceAppender" />
      <appender-ref ref="ConsoleAppender" />
    </root>
  </log4net>-->
  <connectionStrings>
    <add name="PostgreeDbContext"
         connectionString="Server=localhost;Port=5432;Database=test_UniORM144;User Id=postgres;Password=removed; ApplicationName=UniORM144Test;"
         providerName="Npgsql" />
  </connectionStrings>
  <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
  </startup>
  <appSettings>
    <add key="csvLocationcreate" value="c:\logs\UniORM144_test_create.csv" />
    <add key="csvLocationretrieve" value="c:\logs\UniORM144_test_retrieve.csv" />
    <add key="csvLocationupdate" value="c:\logs\UniORM144_test_update.csv" />
    <add key="csvLocationdelete" value="c:\logs\UniORM144_test_delete.csv" />

  </appSettings>
</configuration>