public string ConnectionString
{
get
{
if (ConfigurationManager.ConnectionStrings["conn"] == null ||
String.IsNullOrEmpty(ConfigurationManager.ConnectionStrings["conn"].ConnectionString) == true)
{
throw new InvalidOperationException("默认的连接字符串不存在或者为空");
}
return ConfigurationManager.ConnectionStrings["conn"].ConnectionString;
}
}
private DataAccessEntitiesDataContext m_dataContext;
public DataAccessEntitiesDataContext DataContext
{
get
{
if (m_dataContext == null)
{
m_dataContext = new DataAccessEntitiesDataContext(ConnectionString);
m_dataContext.Log = Console.Out;
}
return m_dataContext;
}
}