0
我有3個表:從數據庫中讀取數據並保存在實體中,但是在哪種數據類型中?
1 User (USERID, Name, Age, Phone Number, FK_VennerID)
2: Friends (VENNERID, name, age, gender, FK_LokationID)
3: Location (LOKATIONID, Zip code, city name)
基於3個表,我已經maked實體模型像這樣在我的asp.net程序:
public class User
{
public int USERID {get; set;}
public string Name {get; set;}
public int Age {get; set;}
public int Phone Number {get; set;}
public virtual ICollection <Venner> Friends {get; set;}
}
public class Friends
{
public int VENNERID {get; set;}
public string Name {get; set;}
public int Age {get; set;}
public int LokationID {get; set;}
public virtual User User {get; set;}
public virtual Location Location {get; set;}
}
public class Location
{
public int LokationID {get; set;}
public int Zip {get; set;}
public string Town {get; set;}
public virtual ICollection <Venner> Friends {get; set;}
}
現在讓我們假設我有在我的數據庫中定義的SQL存儲過程,這需要1個輸入參數,並讓我從3代表以下數據:
User.name,
Friends.name,
Friends.age,
lokation.Zip,
Lokation.Town
洙如何保存從SQL SPOC所以數據我n實體對象。
如果數據只有一種類型,我可以這樣做:
User user = new User();
user.navne = datafrabasen;
user.xx = datafrabasen;
但是現在我們已經從混合基地,同時具有用戶類朋友類和類的位置做數據..
我想將數據庫中的數據保存到列表中...可以從字體層調用!
Return to List <Type> xxxx();
這是正常的方式做到這一點? 爲什麼把我分成三種類型後列表...它會使性能不佳..? – user1032019