数据字典添加对象

public class Et_ErrorType
{
[Key]
public int Et_Id { get; set; }
public string Et_Type { get; set; }
public string Et_Instructions { get; set; }
public string Et_Note { get; set; }
}

1.把数据库返回的对象添加进数据字典

Dictionary<int, Et_ErrorType> dic = new Dictionary<int, Et_ErrorType>();
var ErrorType = _errorTypeService.ErrorTypeSelect();//数据库返回对象
int i = 0;
foreach (var et in ErrorType)
{
Et_ErrorType e_t = new Et_ErrorType();
e_t.Et_Id = et.Et_Id;
e_t.Et_Instructions = et.Et_Instructions;
e_t.Et_Note = et.Et_Note;
e_t.Et_Type = et.Et_Type;
dic.Add(i, e_t);
i++;
}

 

posted on 2015-11-11 17:28  Andy_陈  阅读(505)  评论(0)    收藏  举报

导航