示例#1
0
        /// <summary>
        /// 선박 제원정보 저장
        /// </summary>
        /// <param name="csvFileData"></param>
        private void CopyToDataBaseFromVesselInfomation(DataTable csvFileData)
        {
            cssVesselInfo        vi      = new cssVesselInfo();
            List <cssVesselInfo> lstData = vi.DataTableToClass(csvFileData);

            var bulk = new BulkOperations();

            // var VesselInfo = new List<VesselInfo>();

            using (TransactionScope trans = new TransactionScope())
            {
                using (SqlConnection conn = new SqlConnection(connectionString))
                {
                    bulk.Setup <cssVesselInfo>()
                    .ForCollection(lstData)
                    .WithTable("VesselInfo")
                    .AddAllColumns()
                    .BulkInsertOrUpdate()
                    //.SetIdentityColumn(x => x.clsgn)
                    .MatchTargetOn(x => x.clsgn)
                    .Commit(conn);
                }

                trans.Complete();
            }
        }
示例#2
0
        }                                                                               //        검사기관

        public List <cssVesselInfo> DataTableToClass(DataTable dt)
        {
            List <cssVesselInfo> lstData = new List <cssVesselInfo>();

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                cssVesselInfo  vi    = new cssVesselInfo();
                PropertyInfo[] props = vi.GetType().GetProperties(BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);

                foreach (var property in props)
                {
                    string colName = string.Empty;
                    if (VesselDetailInfo.TryGetValue(property.Name, out colName))
                    {
                        property.SetValue(vi, dt.Rows[i][colName].ToString());
                    }
                }

                lstData.Add(vi);
            }


            return(lstData);
        }