实体这是模型我有我使用LINQ绑定泛型列表里面enity
public class Physician
{
public Physician()
{
PhysicianAddress = new Address();
}
public int PhysicianId { get; set; }
public string NPI { get; set; }
public string PhysicianPrefixName { get; set; }
public string PhysicianFirstName { get; set; }
public string PhysicianMiddleName { get; set; }
public string PhysicianLastName { get; set; }
public string PhysicianPhoneExt { get; set; }
public string PhysicianPhoneNum { get; set; }
public string PhysicianFaxNum { get; set; }
public string PhysicianEmailAddr { get; set; }
public string PhysicianComment { get; set; }
public List<Site> PracticeLocationsList { get; set; }
public Address PhysicianAddress { get; set; }
public int? MergedIntoPhysicianId { get; set; }
}
我从StoredProcedure的获取数据,然后我绑定的返回结果模型
数据绑定到它var physicians = (from sp in e.GetSitePhysicians((int)request.SiteId)
select new Physician()
{
PhysicianId = sp.PhysicianId,
PhysicianFirstName = sp.PhysicianFirstName,
PhysicianMiddleName = sp.PhysicianMiddleName,
PhysicianLastName = sp.PhysicianLastName,
NPI = sp.NPI,
PhysicianPhoneNum = sp.PhysicianPhoneNum,
PhysicianFaxNum = sp.PhysicianFaxNum,
PhysicianEndDate = sp.PhysicianEndDate,
PhysicianEffectiveDate = sp.PhysicianEffectiveDate,
PhysicianComment = sp.PhysicianComment,
AddressId = sp.AddressId,
PhysicianEmailAddr = sp.PhysicianEmailAddr,
PhysicianPhoneExt = sp.PhysicianPhoneExt,
PhysicianAddress = new Address()
{
SiteAddressId = sp.SiteAddressId ?? 0,
Street1 = sp.SiteAddressStreet1 ?? string.Empty,
Street2 = sp.SiteAddressStreet2 ?? string.Empty,
City = sp.SiteAddressCityName ?? string.Empty,
PostalCode = sp.SiteAddressPostalCode ?? string.Empty,
State = sp.GeographicalStateProvinceCode ?? string.Empty,
ParkingInstructions = sp.SiteAddressParkingInstructions ?? string.Empty,
},
PracticeLocationsList=new Site()
{
Id = sp.SiteId,
Name = sp.SiteName,
SiteMainPhoneNum = sp.SiteMainPhoneNum,
Address = new Address
{
SiteAddressId = sp.SiteAddressId??0,
Street1 = sp.SiteAddressStreet1,
Street2 = sp.SiteAddressStreet2,
City = sp.SiteAddressCityName,
PostalCode = sp.SiteAddressPostalCode,
State = sp.GeographicalStateProvinceCode
},
Contacts = new List<SiteContact>() { new SiteContact() }
}
}).ToList();
当我尝试绑定我的网站对象到PracticeLocationsList它会产生编译时错误,“不能隐式转换类型'网站'为'System.Collections.Generic.List'”。
如何将我的网站对象转换为列表,然后绑定?
我标志着这是因为答案首先@Yahya了答案。 – praveen