コード例 #1
0
        public static IDbConnection GetConnection()
        {
            var factory = new SqlServerDbConnectionFactory(conStr);
            var conn    = DbConnectionFactoryHelper.New(factory, profiler);

            return(conn);
        }
コード例 #2
0
        public DbConnection GetSmartCDRConnection()
        {
            this.connString = ConfigurationManager.ConnectionStrings["SMARTCDR"].ConnectionString;
            var connectionFactory = new SqlServerDbConnectionFactory(this.connString);

            return(DbConnectionFactoryHelper.New(connectionFactory, CustomDbProfiler.Current));
            //return new SqlConnection(this.connString);
        }
コード例 #3
0
        public void JobsDBOperationsTest()
        {
            //IDbConnection db = DBConnection.GetConnection();
            var factory = new SqlServerDbConnectionFactory("Data Source=.;Initial Catalog=HTCCRMPortal;Integrated Security=True;");

            using (var db = DbConnectionFactoryHelper.New(factory, CustomDbProfiler.Current))
            {
                Job job1 = new Job()
                {
                    //Id = 4,
                    CustomerId       = 1,
                    Name             = "XYZ Corp Carpet Install",
                    Description      = "Replacing carpet in XYZ corporate offices",
                    StartDate        = Convert.ToDateTime("11/29/2017"),
                    CompletionDate   = Convert.ToDateTime("12/31/9999"),
                    ProjectManagerId = 1,
                    AccountManagerId = 2,
                    EstimatedCost    = 25000.0000M,
                    EstimationNotes  = null,
                    POCost           = 20000.0000M,
                    POStatus         = "Not Paid",
                    VarianceNotes    = "",
                    StreetAddress    = "253 Hotel Road",
                    City             = "Auburn",
                    State            = "ME",
                    Zip         = "04210",
                    Latitude    = 0,
                    Longitude   = 0,
                    IsDeleted   = true,
                    WhenCreated = Job.GetById <Job>(db, 4).WhenCreated,
                    ValidToDate = Convert.ToDateTime("9999-12-31")
                                  //MasterId = 4
                };

                //Console.WriteLine(job1.MasterId);

                //Job.Persist<Job>(db, job1);
                // Console.WriteLine("SQL statement: " + CustomDbProfiler.Current.ProfilerContext.GetCommands());
                //Job job2 = Job.GetById<Job>(db, 4);

                //job2.Name = "ABC Carpet Install";
                // job2.Persist<Job>(db);

                //IEnumerable<Job> jobs1 = Job.GetAll<Job>(db);
                //IEnumerable<Job> jobs2 = Job.GetAll<Job>(db, false, false);
                //IEnumerable<Job> jobs3 = Job.GetAll<Job>(db, true, true);
                //IEnumerable<Job> jobs4 = Job.GetAll<Job>(db, true, false);

                //Assert.AreEqual(18, jobs1.Count());
                //Assert.AreEqual(18, jobs2.Count());
                //Assert.AreEqual(21, jobs3.Count());
                //Assert.AreEqual(19, jobs4.Count());

                var jobs = Job.GetBySubContractorId(db, 1);
            }
        }