我想创建一个带有主键阴影的表(不在模型中)。
public class Person
{
public string Name { get; set; }
}
public class PersonEntityTypeConfiguration : IEntityTypeConfiguration<Person>
{
public void Configure(EntityTypeBuilder<Person> builder)
{
builder.Property?
builder.HasKey("Id")????
}
}
Run Code Online (Sandbox Code Playgroud)
注意:实际情况是不同的类和值对象(DDD)。
我将 API 配置分为两个项目(主要项目和次要项目)。在主体 Startup.cs 中,我配置 Autofac,并在辅助中使用主体返回的 IServiceCollection。
为了注册 Autofac 模块,我应该编码:
public IServiceProvider ConfigureServices(IServiceCollection services)
{
services.AddMvc();
var container = new ContainerBuilder();
container.Populate(services);
container.RegisterModule(new ApplicationModule());
return new AutofacServiceProvider(container.Build()); // Instead of 'return services;'
}
Run Code Online (Sandbox Code Playgroud)
如果您看到返回的类型,它是 IServiceProvider 而不是 IServiceCollection。如何注册模块,但返回 IServiceCollection?我尝试从 IServiceProvider 转换为 IServiceCollection,但引发了异常。
名单是
[2, 3, 4]
Run Code Online (Sandbox Code Playgroud)
我希望对每个结果进行取幂.那么,它将是:
(2 ^ 3)^ 4 = 4096
我的解决方案是
代码是
foldl (^) 2 [1, 3, 4]
Run Code Online (Sandbox Code Playgroud)
跟踪是
((2 ^ 1)^ 3)^ 4 = 4096
有没有改变清单的解决方案?