小编Ste*_*ves的帖子

Haskell:立即从控制台读取输入字符,而不是在换行符之后

我试过这个:

main = do
    hSetBuffering stdin NoBuffering 
    c <- getChar
Run Code Online (Sandbox Code Playgroud)

但它一直等到按下输入,这不是我想要的.我想在用户按下它后立即读取该字符.

我在Windows 7上使用ghc v6.12.1.

编辑:我的解决方法是从GHC转移到WinHugs,它正确支持这一点.

windows io haskell buffering ghc

27
推荐指数
2
解决办法
4974
查看次数

实体框架4 - 代码优先和存储过程

我想用一个参数执行存储过程,该参数使用EF4"Code First"返回表.我只是为了这个目的而使用一些DTO,它不需要返回实体.我试过:

a)使用函数import创建edmx文件并将其添加到我的ObjectContext,如下所示:

protected override void OnModelCreating(ModelBuilder modelBuilder)
{
    modelBuilder.RegisterEdmx("Model.edmx");
}
Run Code Online (Sandbox Code Playgroud)

但是我InvalidOperationException说"在使用Fluent API进行代码优先配置后,无法使用现有模型的注册".

b)访问underling连接并执行以下过程:

    var connection = this.objectContext.UnderlyingContext.Connection;
    connection.Open();
    DbCommand command = connection.CreateCommand();
    command.CommandType = CommandType.StoredProcedure;
    command.CommandText = "booklog.Recommendations";
    command.Parameters.Add(
        new EntityParameter("userId", DbType.Guid) { Value = this.userId });
    var reader = command.ExecuteReader();
    // etc.
Run Code Online (Sandbox Code Playgroud)

哪里

public class MyObjectContext : DbContext
{
    public System.Data.Objects.ObjectContext UnderlyingContext
    {
        get { return this.ObjectContext; }
    }

    // ....
 }
Run Code Online (Sandbox Code Playgroud)

但这种方法不起作用.它抛出InvalidOperationException消息"在当前工作空间中找不到为FunctionImport指定的容器'booklog'."

.net stored-procedures entity-framework code-first

2
推荐指数
1
解决办法
5004
查看次数

strtod和下溢

我想在使用strtod函数在C++(Visual C++ 2010)中将字符串转换为double时检测下溢.下面的代码不能像我期望的那样工作,尽管我是根据strtod文档做的:

 char numStr[] = "123456.122111111123123123123132123123123123123124434345345";
 char* pEnd;
 double d = strtod(numStr, &pEnd);
 int errorNum = errno;
 if (errorNum == ERANGE) // this should be true
 {
  // underflow occurred
 }
Run Code Online (Sandbox Code Playgroud)

使用调试器,我发现errorNum总是被设置为0ERANGE34.

我错过了什么?

c c++ type-conversion visual-c++

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