小编for*_*rir的帖子

刷新实体框架3.5中的存储过程

我使用.NET 3.5 SP1,VS 2008与实体框架.我最初在我的模型中添加了一个存储过程,它带有2个参数.后来,我改变了sproc只需要1个参数.我运行了Update Model From Database菜单选项并确认我的sproc已列在Refresh选项卡中.完成向导,清理并重建解决方案,模型从未改变过sproc的签名.

为什么不更新?数据库功能的更新模型是否已损坏?我错过了什么吗?谢谢.

stored-procedures entity-framework visual-studio-2008

54
推荐指数
3
解决办法
4万
查看次数

如何检查另一个字符串中是否存在字符串

希望有人可以帮助我.我刚刚学习C#,我有一个简单的问题.

我有一个变量,我想检查是否存在于另一个字符串中.就像是

if ( test contains "abc" ) {

}
Run Code Online (Sandbox Code Playgroud)

有没有一种简单的方法在C#中执行此操作

c#

39
推荐指数
5
解决办法
8万
查看次数

检查对于异步方法的Received()调用

当我运行以下代码时:

[Test]
public async Task Can_Test_Update()
{
    var response = await _controller.UpdateAsync(Guid.NewGuid());
    response.Valid.Should().BeTrue();

    _commands.Received().UpdateAsync(
        Arg.Is<Something>(
            l => l.Status == Status.Updated)); 
}
Run Code Online (Sandbox Code Playgroud)

如果我在" await"之前添加" " _commands.Received().UpdateAsync,它会抛出一个空引用异常.我怎样才能阻止这种情况发生,或者await不是必要的?

c# asynchronous nsubstitute async-await

18
推荐指数
4
解决办法
8177
查看次数

在VS2015中运行C#单元测试时会有很长的延迟

在VS2015中运行单元测试时,我有很长的延迟(大约1分钟!甚至更多).当运行一个单独的测试时,我看到"测试资源管理器"顶部的进度条,它流动大约一分钟,然后我得到测试结果.报告的测试运行时间与预期一样 - 非常小,几毫秒.

我的问题是 - 我该怎么调试呢?在测试实际开始运行之前,我怎么能看到这一刻发生了什么?

unit-testing visual-studio-2015

18
推荐指数
1
解决办法
3983
查看次数

快速排序(n个数组应视为1,值根据需要重新映射)

我有一个数组的链接列表(在帖子底部的结构)

每个数组可能具有类似下面示例的值

Array1[] = {6,36,8,23};
Array2[] = {8,23,5,73};
Array3[] = {2,5,1,9};
Run Code Online (Sandbox Code Playgroud)

我需要对这些进行排序,以便将所有3个数组视为1个大数组......

我需要使用quicksort,以便它使用就地处理...我正在使用非常大的数组,并且不能使用额外的内存..

结果应该是这样的

Array1[] = {1,2,5,5};
Array2[] = {6,8,8,9};
Array3[] = {23,23,36,73};
Run Code Online (Sandbox Code Playgroud)

目前我只能单独对每个数组进行排序......但这不完全是我需要的:(

struct iSection {
    unsigned long     Section_Count; // Total # of points in this block of memory

    int              *Section_Arr;   // Point cloud for current block of memory
    struct iSection  *Next;          // Pointer to next section
} iSection;


struct iDatabase {
    struct iSection     *First_Section;
    struct iSection     *Last_Section;
} iDatabase;
Run Code Online (Sandbox Code Playgroud)

c c++

15
推荐指数
1
解决办法
287
查看次数

dict函数有些问题

我正在尝试使用该dict函数将列表转换为字典.

inpu = input.split(",")
dic = dict(inpu)
Run Code Online (Sandbox Code Playgroud)

上面的代码正在试图获得一个字符串,split','事后我使用dict功能的列表转换为一个字典.

但是,我收到此错误:

ValueError:字典更新序列元素#0的长度为6; 2是必需的

有人可以帮忙吗?

python

13
推荐指数
1
解决办法
3万
查看次数

使用通配符和通配符的问题

我有一个方法,返回map定义为:

public Map<String, ?> getData();
Run Code Online (Sandbox Code Playgroud)

这个方法的实际实现对我来说并不清楚,但是,当我尝试这样做时:

obj.getData().put("key","value")
Run Code Online (Sandbox Code Playgroud)

我得到以下编译时错误消息:

方法put(String,capture#9-of?)在Map类型中不适用于参数(String,String)

问题是什么?是String不是输入任何内容?

提前致谢.

java generics arguments wildcard map

11
推荐指数
3
解决办法
1万
查看次数

Eclipse c ++如何使用现有的makefile

我是新手,我有一个问题!我将使用c ++代码,我不知道如何导入它以及如何在eclips上编译它(我通过命令行编译它).代码具有特定的结构,并以这种方式组织:

repos____lib____configure (execute the configure file inside the libraries folders)
                  I           I___makefile (execute the make file inside the libraries folders,
                                                        requires make/make.def)
      I           I___ib1____.cpp
      I           I            I____.h
      I           ...          I____configure (it requires make/configure_lib and
                                                              make/configure_includes
      I           ...          I____makefile (generated by configure)
      I           I___lib2___....
      i           I___.......
      I           I___libn____.cpp
      i                        I____.h
      i                        I____configure
      i                        I____makefile (generated by configure)
      I
      I___make(folder)__bashrc (are set the some environment variables)
      I                               I__configure_bin
      I                               I__configure_includes
      I                               I__configure_lib
      I                               I__make.def (are set all the include path and …
Run Code Online (Sandbox Code Playgroud)

c++ eclipse makefile

11
推荐指数
1
解决办法
9076
查看次数

如何阻止Visual Studio构建未更改的依赖项?

标题相当简单.如果我点击构建按钮,它就像"全部重建"按钮.如果我有两个项目,让我们称它们为PARENT和CHILD,然后我对Parent进行更改并单击"Build"按钮.VS中的默认行为是重建PARENT AND CHILD,它只应重建PARENT.

我想知道这是否是Visual Studio中的一个选项以及我如何更改它.

谢谢.

dependencies build visual-studio-2010

11
推荐指数
4
解决办法
1万
查看次数

使用手动事务和分层事务进行单元测试

由于一些限制,我无法使用实体框架,因此需要手动使用SQL连接,命令和事务.

在为调用这些数据层操作的方法编写单元测试时,我偶然发现了一些问题.

对于单元测试,我需要在事务中执行它们,因为大多数操作都是按其性质更改数据,因此在事务之外执行它们会产生问题,因为这会改变整个基础数据.因此,我需要围绕这些进行事务处理(最后没有提交任何提交).

现在我有两种不同的变体,这些BL方法的工作方式.一些交易本身就在其中,而其他交易本身则没有交易.这两种变体都会引起问题.

  • 分层事务:在这里我得到DTC由于超时而取消分布式事务的错误(尽管超时设置为15分钟且运行仅2分钟).

  • 只有1个事务:当我来到"new SQLCommand"被调用方法的行时,我得到一个关于事务状态的错误.

我的问题是如何解决这个问题并通过手动普通和分层交易进行单元测试?

单元测试方法示例:

using (SqlConnection connection = new SqlConnection(Properties.Settings.Default.ConnectionString))
{
    connection.Open();
    using (SqlTransaction transaction = connection.BeginTransaction())
    {
        MyBLMethod();
    }
}
Run Code Online (Sandbox Code Playgroud)

使用方法的事务示例(非常简化)

using (SqlConnection connection = new SqlConnection(Properties.Settings.Default.ConnectionString))
{
    connection.Open();
    using (SqlTransaction transaction = connection.BeginTransaction())
    {
        SqlCommand command = new SqlCommand();
        command.Connection = connection;
        command.Transaction = transaction;
        command.CommandTimeout = 900;   // Wait 15 minutes before a timeout
        command.CommandText = "INSERT ......";
        command.ExecuteNonQuery();

        // Following commands
        ....

        Transaction.Commit();
    }
}
Run Code Online (Sandbox Code Playgroud)

非Transaction使用方法的示例

using …
Run Code Online (Sandbox Code Playgroud)

c# sql unit-testing transactions

11
推荐指数
1
解决办法
1342
查看次数