public static void BuildColorLab() { StorageDataContext sdc = new StorageDataContext(); var l = sdc.Color.ToList(); l.ForEach(p => { Console.WriteLine("开始转化,颜色:" + p.Name + " RGB:" + p.RGB); int r = System.Convert.ToInt32(p.RGB.Substring(1, 2), 16); int b = System.Convert.ToInt32(p.RGB.Substring(3, 2), 16); int g = System.Convert.ToInt32(p.RGB.Substring(5, 2), 16); var lab = LabRgb.RgbToLab(new int[] { r, b, g }); p.Lab_L = lab[0]; p.Lab_a = lab[1]; p.Lab_b = lab[2]; }); sdc.SaveChanges(); Console.WriteLine("全部转换完成。"); Console.ReadKey(); }