我正在構建通用的共享點DALL,所以我需要幫助。 我不知道這是否適用,但它邏輯上它必須是。通用類的調用方法
我的問題是我的gr8 TTL不確定他需要使用什麼數據源:S(SQL或SharePoint列表),他需要爲項目開始開發。
所以我需要建立DAL作爲SP列表是我的數據源,所以未來的變化將最小化。
現在我已經是baseDAL包括所有常見的操作,例如刪除,GETALL ,,,等
myBase DAL類現在類似
public class BaseDAL<T> where T : BaseInfo,new()
{
public virtual List<T> GetAllItem()
{
//code to read from any data source and return data
}
public virtual Boolean Delete(T entity)
{
int entityID = ((BaseInfo)entity).ID;
deleteEntity(entityID);
}
}
和我有baseInfo作爲主要的業務對象實體。
,並讓說,我有兩個實體企業(員工,學生)和兩個DAL一個員工,一個用於學生
所以我在想什麼正在實施getAllItem代碼returnes基於在T型所有項目,所以代碼可能看起來像波紋管在baseDAL
public virtual List<T> GetAllItem()
{
SPListItemCollection items = //code to read from list please note that list name saved in baseInfo object
T.getBusinessListItems(items); //toList
}
和EmployeeDAL我實現SPListItemCollection之間的映射功能,以企業實體的代碼將被samiliare這個
public virtual List<Employee> getBusinessListItems(SPListItemCollection items)
{
//loop the items and fill them in list of employee objects
return list<Employee>
}
希望這個澄清的情況下,我不知道這是寫的方式做到這一點我不是一個技術人員。如果還有其他方法可以做,請幫忙。
我不能理解你的問題..你想要做什麼... – Anirudha
我已經添加一個C#的標籤,因爲我認爲這是C#。如果不是這樣,請更改它。 –
特別是'T.toList'部分!你想在這裏做什麼...... – Anirudha