-1

Attempting another tack on this question: Attempting to use OOPFactory to parse 271 benefits using EligibilityBenefitDocument

This time, instead of attempting to use the object directly, I'm attempting to use a different part of the library to write what exists into sql.

I'm attempting to execute the class OOPFactory.X12.ImportX12.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;
using OopFactory.X12.Parsing;
using OopFactory.X12.Repositories;
using OopFactory.X12.Sql;
using System.IO;
using System.Diagnostics;
namespace OopFactory.X12.ImportX12
{
    class Program
    {
        enum testc { incrementme };
        static void Main(string[] args)
    {
        string dsn = ConfigurationManager.ConnectionStrings["X12"].ConnectionString;

        bool throwExceptionOnSyntaxErrors = ConfigurationManager.AppSettings["ThrowExceptionOnSyntaxErrors"] == "true";
        string[] segments = ConfigurationManager.AppSettings["IndexedSegments"].Split(',');
        string parseDirectory = ConfigurationManager.AppSettings["ParseDirectory"];
        string parseSearchPattern = ConfigurationManager.AppSettings["ParseSearchPattern"];
        string archiveDirectory = ConfigurationManager.AppSettings["ArchiveDirectory"];
        string failureDirectory = ConfigurationManager.AppSettings["FailureDirectory"];
        string sqlDateType = ConfigurationManager.AppSettings["SqlDateType"];
        int segmentBatchSize = Convert.ToInt32(ConfigurationManager.AppSettings["SqlSegmentBatchSize"]);

        var specFinder = new SpecificationFinder();
        var parser = new X12Parser(throwExceptionOnSyntaxErrors);
        parser.ParserWarning += new X12Parser.X12ParserWarningEventHandler(parser_ParserWarning);
        var repo = new SqlTransactionRepository<int>(dsn, specFinder, segments, ConfigurationManager.AppSettings["schema"], ConfigurationManager.AppSettings["containerSchema"], segmentBatchSize, sqlDateType);

        //var repo = new OopFactory.X12.Sql.SqlTransactionRepository(dsn,"test");
        //var repo = new OopFactory.X12.Sql.SqlTransactionRepository(dsn,new testc());

Out of the box, I get the error 'OopFactory.X12.Repositories.SqlTransationRepository' is obsolete: 'Use OopFactory.X12.Sql library and namespace'

Attempting to respond to that, I add a using clause to the top to import that namespace and attempt to invoke that method directly (as seen in my commented invocations of the repo variable).

  • When I attempt to apss it a string, it tells me "The best overloaded method match for 'OopFactory.X12.Sql.SqlTransactionRepository....' has some invalid arguments
  • I also get that when i attempt to pass in an instance of an enum.

My question is this: How do I invoke a method requiring a parameter of System.Type?

I'll also be sure to vote up the first few responses that can correctly t points if you can tell me what they're actually expecting to be passed into the method signature for SqlTransactionRepository

public SqlTransactionRepository(string dsn, Type identityType)
        : this(dsn, new SpecificationFinder(), new[] { "REF", "NM1", "N1", "N3", "N4", "DMG", "PER" }, identityType, "dbo")
    {
    }
Community
  • 1
  • 1
vesuvian7
  • 71
  • 1
  • 7

2 Answers2

0

Lets say that your Type is Person,

You can use typeof(Person):

 SqlTransactionRepository(dsn, typeof(Person));

Or get the type of an instance of person:

 Person p = new Person();
 SqlTransactionRepository(dsn, p.GetType());
Erez.L
  • 77
  • 1
  • 10
0

According to the documentation inside the source code (OopFactory X12 Parser)

The identity parameter should have:

the type of all identity columns

and it supports either int or long, meaning you should pass either:

typeof(int)

or

typeof(long)

Hope it helps!

Itay Podhajcer
  • 2,616
  • 2
  • 9
  • 14