示例#1
0
        protected void PersistEntities <T, U>(Connection connection, Guid projectId, CSVFile file, string dtype = "")
            where T : BaseEntity
            where U : BaseDto
        {
            if (file == null)
            {
                return;
            }

            List <T> entities = new List <T>();
            CSVRow   header   = file.GetHeader();

            foreach (CSVRow row in file.GetValues())
            {
                CSVValue dtypeValue = file.GetValueToColumn(row, "DTYPE");
                if (dtypeValue != null && !string.IsNullOrEmpty(dtype))
                {
                    if (!dtype.Equals(dtypeValue.GetValue()))
                    {
                        continue;
                    }
                }
                entities.Add(CreateEntity <T, U>(file, row, projectId));
            }
            GenericRepository genericRepository = new GenericRepository(connection);

            genericRepository.PersistAsNews <T>(entities);
        }