使用Entity Framework 6.1代码优先模型,将表上的聚簇索引从默认ID更改为另一组列的最佳方法是什么.Azure不允许没有聚簇索引的表.
public partial class UserProfile
{
public override Guid ID { get; set; }
[Index( "CI_UserProfiles_UserID", IsClustered = true)]
public Guid UserID { get; set; }
[Required]
public Guid FieldID { get; set; }
[Required]
[StringLength(400)]
public string Value { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
在表上UserProfiles,ID已经是主键和聚簇索引.添加
[Index( "CI_UserProfiles_UserID", IsClustered = true)]
Run Code Online (Sandbox Code Playgroud)
到UserID创建此迁移:
CreateIndex("dbo.UserProfiles", "UserID", clustered: true, name: "IX_UserProfiles_UserID");
Run Code Online (Sandbox Code Playgroud)
执行迁移会生成以下错误:
无法在表'dbo.UserProfiles'上创建多个聚簇索引.删除现有的聚簇索引"PK_dbo.UserProfiles",然后再创建另一个.
我正在尝试通过 REST 使用 GitHub V3 API 分叉一个存储库,但是,我在按照文档发出 POST 请求时遇到问题(https://developer.github.com/v3/repos/forks/#create-一把叉子)。
基本上,到目前为止我所拥有的:
https://api.github.com/repos/carmichaelalonso/infiniteflight/forks/- 我首先使用 hurl.it 对此进行测试。Authorization值为“token ...”,另一个标头的Content-Type值指定application/json{"organization" : "shortlisthome"}(shortlisthome 是我尝试将存储库分叉到的帐户。我不打算将其分叉给一个组织,而不是一个标准用户帐户,这就是我感到困惑的地方。当我运行请求时,我没有收到任何身份验证错误或 404 错误(我以前有过,但我错误地输入了不正确的值,导致了此类错误)。
当我运行此请求时,我得到以下结果(422 无法处理的请求):
{
"message": "Validation Failed",
"documentation_url": "---url-to-docs---",
"errors": [
{
"resource": "Fork",
"code": "invalid",
"field": "organization"
}
]
}
Run Code Online (Sandbox Code Playgroud)
我不确定我是否能够将其分叉给标准用户,或者这是否是我的请求的错误。如果我可以提供更多信息,请告诉我(这里是第一篇文章,所以对惯例有点不熟悉)。谢谢!
我无法在启动时将我的自定义保存ConfigurationSection在我的web.config文件中.
我已经按照本教程进行了通用实现.我的单元测试通过了,我能够ConfigurationSection在单元测试中保存de !
在应用程序启动时,我想ClaimCollection基于控制器类名和所属方法名建立一个:
Startup.cs
public void Configuration(IAppBuilder app)
{
Config = new HttpConfiguration();
BuildUnityContainer();
BuildClaimCollection(); <----------------
ConfigureOAuth(app);
WebApiConfig.Register(Config);
app.UseCors(Microsoft.Owin.Cors.CorsOptions.AllowAll);
app.UseWebApi(Config);
}
public void BuildClaimCollection()
{
//config section
MethodClaimSection methodClaimSection = BaseConfigurationSection<MethodClaimSection>.Open();
var methods = GetClaimAuthorizedMethods();
foreach (var method in methods)
{
var claimValue = GetClaimValueFromMethodName(method);
var claim = new MethodClaimElement()
{
Type = "Method",
Value = claimValue
};
methodClaimSection.MethodClaims.Add(claim);
}
methodClaimSection.Save();
}
Run Code Online (Sandbox Code Playgroud)
BaseConfigurationSection.cs
public abstract class BaseConfigurationSection<T> : ConfigurationSection …Run Code Online (Sandbox Code Playgroud) 我正在使用strongloop的loopbackjs来实现API.
对于Cat我定义了远程方法的模型,我们可以调用它meow.
所以我能做到:
GET /cats/{:id}/meow
该Cat模型属于该User模型.
现在我希望能够做到这样的事情:
GET /users/{:id}/cats/{:id}/meow
有谁知道如何做到这一点?
我已经尝试过nestRemoting,它只适用于嵌套的"蓝图"方法.
如果我在库中定义了一个辅助类,但我不想在库外部使用它,那么在类名前面放置下划线的正确隐藏机制是否正确?
part of foo;
class Bar { } // made available to users of the foo library
class _BarHelp { } // hidden from users of the foo library
Run Code Online (Sandbox Code Playgroud)
或者是否有其他隐藏 BarHelp 的方法?
所以我正在创建 dll 类型文件,运行它们,然后我想删除它们。
然而,当我尝试删除它们时,我得到一个异常,因为它声称它们仍在被另一个进程使用。
我假设用于创建文件的代码没有正确处理资源以允许删除文件,这是我创建文件的代码。
if (!Directory.Exists(PathToRobots + Generation))
{
Directory.CreateDirectory(PathToRobots + Generation);
}
File.WriteAllText(Path.Combine(PathToRobots + Generation, NameSpace + GetRobotName() + robotNumber + ".cs"), code);
CSharpCodeProvider provider = new CSharpCodeProvider();
CompilerParameters parameters = new CompilerParameters()
{
GenerateInMemory = false,
GenerateExecutable = false, // True = EXE, False = DLL
IncludeDebugInformation = true,
OutputAssembly = Path.Combine(FileName + ".dll") // Compilation name
};
parameters.ReferencedAssemblies.Add(@"robocode.dll");
CompilerResults results = provider.CompileAssemblyFromSource(parameters, code);
if (results.Errors.HasErrors)
{
StringBuilder sb = new StringBuilder();
foreach (CompilerError error in results.Errors) …Run Code Online (Sandbox Code Playgroud) 我正在尝试为一个类(在.net Core项目中)编写一个xunit测试,它看起来像:
public Class FoodStore:IFoodStore
{
FoodList foodItems;
public FoodStore(IOptions<FoodList> foodItems)
{
this.foodItems = foodItems;
}
public bool IsFoodItemPresentInList(string foodItemId)
{
//Logic to search from Food List
}
}`
Run Code Online (Sandbox Code Playgroud)
注意:FoodList实际上是一个包含数据的json文件,它在Startup类中加载和配置.
如何编写带有适当依赖注入的xunit测试来测试IsFoodItemPresentInList方法?
dependency-injection xunit xunit.net asp.net-core asp.net-core-1.0
我个人还没有使用FxCop.我们希望在进行代码分析之前先完成单元测试.但是,你会永久停用哪些规则?您会暂时停用哪些规则以及在哪种情况下停用?
我有这个HTML div,它使用该ngMouseover指令通过函数从api获取一些数据,如下所示:
标记:
<div ng-mouseover="getData()">
</div>
Run Code Online (Sandbox Code Playgroud)
控制器:
$scope.getData = function() {
//get data from api
}
Run Code Online (Sandbox Code Playgroud)
有没有什么方法可以在ngMouseover指令中添加延迟,这样只有在光标在div上停留几秒后才会触发它?就像它debounce在里面一样ngModelOptions.
给出以下用于UserManager的DI类
public class AccountAuthorizationHandler : AuthorizationHandler<OperationAuthorizationRequirement, AuthorisedAccount>
{
private readonly UserManager<ApplicationUser> userManager;
public AccountAuthorizationHandler(UserManager<ApplicationUser> userManager)
{
this.userManager = userManager;
}
protected override void Handle(AuthorizationContext context,
OperationAuthorizationRequirement requirement,
AuthorisedAccount resource)
{
// Pull the user ID claim out from the context.User
var userId = context.User.GetUserId();
// Get the current user's account numbers.
var user = userManager.Users
.Include(u => u.AuthorisedAccounts)
.Where(u => u.Id == userId)
.FirstOrDefault();
//Now check if the user's account numbers match the resource accountNumber, and
foreach( var authorizedAccount in …Run Code Online (Sandbox Code Playgroud) c# ×2
angularjs ×1
api ×1
asp.net-core ×1
azure ×1
dart ×1
file ×1
fxcop ×1
github ×1
github-api ×1
javascript ×1
loopbackjs ×1
rest ×1
rules ×1
xunit ×1
xunit.net ×1