字符串类型转换为GUID类型

               AppRoles r = new AppRoles();
               
                _context.AppRoles.InsertOnSubmit(r);


                var one = collection.GetValues(1)[0];


                Guid gid = new Guid(one);
                r.ApplicationId = gid;//字段为 Guid 类型 


                r.RoleName = collection.GetValues(2)[0].ToString();
                r.LoweredRoleName = collection.GetValues(3)[0].ToString();
                r.Description = collection.GetValues(4)[0].ToString();

                _context.SubmitChanges();              

                return RedirectToAction("Index");

你可能感兴趣的:(字符串类型转换为GUID类型)