public partial class UserManagerEntities : global::System.Data.Objects.ObjectContext
{
public UserManagerEntities() :
base("name=UserManagerEntities", "UserManagerEntities")
{
this.OnContextCreated();
}
public UserManagerEntities(string connectionString) :
base(connectionString, "UserManagerEntities")
{
this.OnContextCreated();
}
public UserManagerEntities(global::System.Data.EntityClient.EntityConnection connection) :
base(connection, "UserManagerEntities")
{
this.OnContextCreated();
}
partial void OnContextCreated();
public global::System.Data.Objects.ObjectQuery<Employee> Employee
{
get
{
if ((this._Employee == null))
{
this._Employee = base.CreateQuery<Employee>("[Employee]");
}
return this._Employee;
}
}
private global::System.Data.Objects.ObjectQuery<Employee> _Employee;
public void AddToEmployee(Employee employee)
{
base.AddObject("Employee", employee);
}
}
其中的一行代码:
this._Employee = base.CreateQuery<Employee>("[Employee]");
中括号里的参数"[Employee]"该怎么理解呢:
按照MSDN中的解释,这里需要两个参数的:
public ObjectQuery<T> CreateQuery<T>(
string queryString,
params ObjectParameter[] parameters
)
类型参数
T
参数
queryString
类型:System..::.String
要执行的查询字符串。
parameters
类型:array<System.Data.Objects..::.ObjectParameter>[]()[]
要传递到查询的参数。
返回值
类型:System.Data.Objects..::.ObjectQuery<(Of <(T>)>)
一个可供执行的对存储区的 ObjectQuery<(Of <(T>)>)。