示例#1
0
        private int InsertCpu()
        {
            string cpu         = this.boxSet.GetCpuAndCpuProducer().Item1;
            string cpuProducer = this.boxSet.GetCpuAndCpuProducer().Item2;

            CustomComputersAspEntities db = new CustomComputersAspEntities();
            Cpu match = db.Cpus.FirstOrDefault(c => c.name == cpu && c.producer == cpuProducer);

            if (match == null)
            {
                db.AddToCpus(new Cpu()
                {
                    name     = cpu,
                    producer = cpuProducer
                });
                db.SaveChanges();
                match = db.Cpus.FirstOrDefault(c => c.name == cpu && c.producer == cpuProducer);
            }
            return(match.id);
        }
示例#2
0
        private int InsertCpu()
        {
            string cpu = this.boxSet.GetCpuAndCpuProducer().Item1;
            string cpuProducer = this.boxSet.GetCpuAndCpuProducer().Item2;

            CustomComputersAspEntities db = new CustomComputersAspEntities();
            Cpu match = db.Cpus.FirstOrDefault(c => c.name == cpu && c.producer == cpuProducer);
            if (match == null)
            {
                db.AddToCpus(new Cpu()
                {
                    name = cpu,
                    producer = cpuProducer
                });
                db.SaveChanges();
                match = db.Cpus.FirstOrDefault(c => c.name == cpu && c.producer == cpuProducer);
            }
            return match.id;
        }