缓存Linq的mappingSource,提高Linq To SQL的性能,(20%的性能都不至哟)
关键对象AttributeMappingSource
[TestMethod]
public void TestMethod1()
{
AttributeMappingSource source = new AttributeMappingSource();
for (int i = 0; i < 10000; i++)
{
//AttributeMappingSource source = new AttributeMappingSource();--》去掉注释试试性能
HRDataContext context = new HRDataContext(connString, source);
var emp = context.GetTable<HR_Employee>().Where(p => p.EmployeeId == 10);
}
}
只要static一下AttributeMappingSource,每次使用就可以了
-----------------------------------
http://www.cnblogs.com/rock_chen/