模型图:
针对一张表DepartMentTB查询:
//实体映射
[Table(Name = "DepartMentTB")]
public class DepartMentTB
{
[Column]
public int ID;
[Column]
public string Code;
[Column]
public string Name;
}
public void Query()
{
DataContext dc = new DataContext("Password=4280;User ID=sa;Initial Catalog=ZhangzsTest;Data Source=192.168.200.156");
var tb = dc.GetTable<DepartMentTB>().ToList();//这里可以使用Where(Lambda表达式)对本表过滤。
foreach (var t in tb)
{
Console.WriteLine("ID="+t.ID.ToString());
}
}
[Table(Name = "DepartMentTB")]
public class DepartMentTB
{
[Column]
public int ID;
[Column]
public string Code;
[Column]
public string Name;
}
public void Query()
{
DataContext dc = new DataContext("Password=4280;User ID=sa;Initial Catalog=ZhangzsTest;Data Source=192.168.200.156");
var tb = dc.GetTable<DepartMentTB>().ToList();//这里可以使用Where(Lambda表达式)对本表过滤。
foreach (var t in tb)
{
Console.WriteLine("ID="+t.ID.ToString());
}
}