本文介绍了dropdownlistfor in mvc Guid to string issue的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我正在尝试在mvc asp.net中填充dropdownlistFor。主键是GUID。 var result2 = db.Divisions.Select(f = > new SelectListItem { Value = f.DivisionID.ToString(), Text = f.DivisionName }); ViewBag.SectionList = result1; 面对ToSring问题() LINQ to Entities无法识别方法'System.String ToString()'方法,并且此方法无法转换为商店表达式。 请建议我解决这个问题。在此先感谢解决方案 试试这个 Value = System.Data.Objects.SqlClient.SqlFunctions。 StringConvert.StringConvert(f.DivisionID) I am trying to populate dropdownlistFor in mvc asp.net . primary key is GUID . var result2 = db.Divisions.Select(f => new SelectListItem{ Value = f.DivisionID.ToString(), Text = f.DivisionName});ViewBag.SectionList =result1; Facing issue in ToSring()LINQ to Entities does not recognize the method 'System.String ToString()' method, and this method cannot be translated into a store expression.Please suggest me some solution of this issue. Thanks in advance 解决方案 Try thisValue = System.Data.Objects.SqlClient.SqlFunctions.StringConvert.StringConvert(f.DivisionID) 这篇关于dropdownlistfor in mvc Guid to string issue的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 10-21 03:12