小编Ada*_*ada的帖子

如何解决hg-fast-export错误:"分支名称不符合GIT标准:refs/heads/master"

在使用Windows上的hg-fast-export工具解决了无数问题之后(从清理mercurial存储库以满足工具需要的finicky python版本)我偶然发现了一个我无法解决的错误:

master: Exporting full revision 1/98 with 142/0/0 added/changed/removed files
fatal: Branch name doesn't conform to GIT standards: refs/heads/master
fast-import: dumping crash report to .git/fast_import_crash_5956
Traceback (most recent call last):
  File "../fast-export/hg-fast-export.py", line 388, in <module>
    options.statusfile,authors=a,sob=options.sob,force=options.force))
  File "../fast-export/hg-fast-export.py", line 322, in hg2git
    c=export_commit(ui,repo,rev,old_marks,max,c,authors,sob,brmap)
  File "../fast-export/hg-fast-export.py", line 214, in export_commit
    export_file_contents(ctx,man,added)
  File "../fast-export/hg-fast-export.py", line 126, in export_file_contents
    wr(d)
  File "../fast-export/hg-fast-export.py", line 28, in wr
    print msg
  File "c:\Python26\lib\site-packages\mercurial\windows.py", line 70, in write
    raise IOError(errno.EPIPE, 'Broken pipe')
IOError: [Errno 32] …
Run Code Online (Sandbox Code Playgroud)

git mercurial

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

使用 Caliburn.Micro 的单实例 WPF 应用程序

我已经看到了有关使用 WPF 创建单实例应用程序的所有其他问题,并且我选择使用此处描述的 Microsoft 方法: https: //codereview.stackexchange.com/a/25667

这工作正常,但现在我想在这个应用程序上使用 Caliburn.Micro,而这段代码不能很好地与 caliburn 配合使用。

如何使用 caliburn micro 拥有单实例 wpf 应用程序?

要求非常简单:.net 4.5 并且每个用户会话只有一个应用程序实例

谢谢

c# wpf single-instance caliburn.micro

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

如何使用AutoMapper"膨胀"实体

我在我的web api项目中收到了一个DTO,我想使用AutoMapper自动将我的DTO转换为我插入数据库的实体.

以下是DTO和实体的简化:

class RegistrationDTO
{
    string name;
    ICollection<int> Departments;
}

class Registration
{
    int id;
    DateTime CreatedAt;
    string name;
    virtual ICollection<Department> Departments;
}

class Department
{
    int id;
    string name;
    virtual ICollection<Registration> Registrations;
}
Run Code Online (Sandbox Code Playgroud)

问题是RegistrationDTO只有部门的ID,我找不到让AutoMapper从数据库中获取部门的方法(使用Entity Framework 5).

使用自定义ValueResolver我可以将一个int列表转换为Departments列表,但是我想从数据库中获取Departments,而不是创建新的Departments.

这是我提出的解决方案,但我很确定有更好的方法:

var reg= Mapper.Map<Registration>(dto);

reg.Departments = new List<int>(dto.Departments).ConvertAll(input => Context.Departments.Find(input));

if(reg.Departments.Contains(null)) //a department provided does not exist in the database
    return Request.CreateResponse(HttpStatusCode.BadRequest, "invalid department");

...
Run Code Online (Sandbox Code Playgroud)

有人可以帮我解决这个问题吗?

c# entity-framework automapper asp.net-web-api

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