我有一个界面
public interface IDataProvider
{
T GetDataDocument<T>(Guid document) where T:class, new()
}
Run Code Online (Sandbox Code Playgroud)
我想以某种方式模拟它,它只会返回给定类型的新实例,而不管确切的类型,如:
myMock.Setup(m => m.GetDataDocument<It.IsAny<Type>()>(It.IsAny<Guid>()))
.Returns(() => new T());
Run Code Online (Sandbox Code Playgroud)
(当然不起作用,因为我不能只给moq提供任何类型参数,我不知道必须返回哪种类型.
关于这个的任何想法?
我在SQL Server 2005上的一个非常小的表(<10行,5列)上运行一个非常简单的查询,通常它会立即返回结果,但有时需要很长时间才能完成(如5-10秒).我知道,我们的服务器负载很重,这可能是原因(因为我认为它不会因锁而发生 - 没有人写入该表) - 但我需要以某种方式找到瓶颈.
关于如何找到确切的服务器资源的任何建议,这使得如此简单的查询运行这么久?
我有一个看起来像的课
public class MyClass
{
public string EmployerName;
public string EmployerSurname;
public string EmploeeName;
public string EmploeeSurname;
}
Run Code Online (Sandbox Code Playgroud)
我已经重构了上面的代码:
public class MyClass
{
public MyClass()
{
Employer = new PersonInfo();
Emploee = new PersonInfo();
}
public class PersonInfo
{
public string Name;
public string Surname;
}
public PersonInfo Emploee;
public PersonInfo Employer;
[Obsolete]
public string EmploeeName
{
get
{
return Emploee.Name;
}
set
{
Emploee.Name = value;
}
}
[Obsolete]
public string EmploeeSurname
{
get
{
return Emploee.Surname;
}
set …Run Code Online (Sandbox Code Playgroud)