日期:2014-05-20 浏览次数:20798 次
public IEnumerable<Tfunction> GetTfunctionListByRole(IList<int> list)
{
using (MyHanMeErDunDbContext db = new MyHanMeErDunDbContext())
{
string sql = "select funcName from Tfunction where ";
for (int i = 0; i < list.Count; i++)
{
if (i == 0)
sql += "funcNo=" + list[0];
else
sql += " or funcNo=" + list[i];
}
var cmd = db.Database.Connection.CreateCommand();
db.Database.Connection.Open();
cmd.CommandText = sql;
List<Tfunction> fslist = new List<Tfunction>();
using (var reader = cmd.ExecuteReader(System.Data.CommandBehavior.SequentialAccess))
{
while (reader.Read())
{
Tfunction ts = new Tfunction();
ts.funcName = reader["funcName"].ToString();
fslist.Add(ts);
}
reader.Close();