Beispiel #1
0
        private void WriteProjectDependencies(IEnumerable <Dependency> dependencies, IDictionary <string, int> projectMap)
        {
            var projectDependencyIntCounter = new IntCounter(-1);
            var projectDependencies         = dependencies
                                              .Select(x => new ProjectDependency
            {
                Id              = projectDependencyIntCounter.Next(),
                ProjectFromId   = projectMap[x.ProjectName],
                ProjectToId     = projectMap[x.Id],
                Version         = x.Version,
                TargetFramework = x.Framework,
                Type            = x.Type.ToString()
            });

            using (var bulkWriter = new BulkWriter <ProjectDependency>(_connectionString))
            {
                bulkWriter.WriteToDatabase(projectDependencies);
            }
        }
Beispiel #2
0
        private IDictionary <string, int> WriteProjects(IEnumerable <Dependency> dependencies)
        {
            var projectIntCounter = new IntCounter(-1);
            var projects          = dependencies
                                    .SelectMany(x => new List <string> {
                x.ProjectName, x.Id
            })
                                    .Distinct()
                                    .Select(x => new Project
            {
                Id   = projectIntCounter.Next(),
                Name = x
            })
                                    .ToList();

            using (var bulkWriter = new BulkWriter <Project>(_connectionString))
            {
                bulkWriter.WriteToDatabase(projects);
            }

            return(projects.ToDictionary(x => x.Name, x => x.Id));
        }