小编Sha*_*ani的帖子

SQL Server中游标的用途是什么?

我想使用数据库游标; 首先,我需要了解它的用途和语法是什么,以及在哪种情况下我们可以在存储过程中使用它?不同版本的SQL Server是否有不同的语法?

什么时候需要使用?

sql-server database-cursor

27
推荐指数
3
解决办法
15万
查看次数

是否可以从Visual Studio使用git stash命令

我正在使用Visual Studio 2017的团队资源管理器来处理git存储库。

每次使用git stash或时git stash pop,我都需要打开Git Bash控制台并导航到我的项目文件夹并运行命令。

有什么办法可以隐藏在Visual Studio(2017)中吗?

git git-stash visual-studio

14
推荐指数
3
解决办法
7348
查看次数

谷歌ReCAPTCHA如何制作所需?

有谁知道如何让" Google ReCAPTCHA(v2) "成为"必需" form

我的意思是在重新填写之前没有表格提交?

我在我的形式中使用ParsleyJs,但没有找到一种方法使它与divs ...

html validation jquery recaptcha parsley.js

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

运行时条件依赖解析器 (.net Core)

我有两个类PaymentGatewayFooPaymentGatewayBoo它们都实现了一个公共接口IPaymentGateway

interface IPaymentGateway { }

class PaymentGatewayFoo : IPaymentGateway { }
class PaymentGatewayBoo : IPaymentGateway { }
Run Code Online (Sandbox Code Playgroud)

客户端请求有一个标识符,用于确定要使用的实现:

public class OrderService
{
    private readonly IPaymentGateway _service;

    public void DoOrder(bool isFoo)
    {
        if (isFoo)
            //this._service should be resolved with PaymentGatewayFoo
        else
            //this._service should be resolved with PaymentGatewayBoo

        this._service.Pay();
    }
}
Run Code Online (Sandbox Code Playgroud)

如何根据客户端在运行时的请求来解决正确的实现?

这个问题不是重复的,它相似但它是关于两个独立的控制器(即使答案表明代码甚至不需要条件依赖注入),在我的情况下,基于客户端属性的运行时需要条件依赖价值。

c# dependency-injection .net-core

10
推荐指数
2
解决办法
5171
查看次数

如何使用身份 2.0 使用授权属性在操作中添加多个策略?

我是身份 2.1.2 和 asp.net core 2.0,我有应用程序声明表,其中包含声明类型和声明值,即资产、资产编辑、资产、资产视图,其中声明类型与不同的声明值相同,我正在创建策略使用对我来说工作正常的声明类型名称不知道如何在一个操作中添加多个策略。下面的代码在启动文件中用于创建策略。

services.AddAuthorization(options =>
{
   var dbContext = SqlServerDbContextOptionsExtensions.UseSqlServer(new DbContextOptionsBuilder<MyDBContext>(),
      Configuration.GetConnectionString("TestIdentityClaimAuth")).Options;

   var dbCon = new MyDBContext(dbContext);
   //Getting the list of application claims.
   var applicationClaims = dbCon.ApplicationClaims.ToList();
   var strClaimValues = string.Empty;
   List<ClaimVM> lstClaimTypeVM = new List<ClaimVM>();
   IEnumerable<string> lstClaimValueVM = null;// new IEnumerable<string>();

   lstClaimTypeVM = (from dbAppClaim
         in dbCon.ApplicationClaims
      select new ClaimVM
      {
         ClaimType = dbAppClaim.ClaimType
      }).Distinct().ToList();

   foreach (ClaimVM objClaimType in lstClaimTypeVM)
   {
      lstClaimValueVM = (from dbClaimValues in dbCon.ApplicationClaims
         where dbClaimValues.ClaimType == objClaimType.ClaimType
         select dbClaimValues.ClaimValue).ToList();

      options.AddPolicy(objClaimType.ClaimType, policy => …
Run Code Online (Sandbox Code Playgroud)

c# claims-based-identity asp.net-core

9
推荐指数
2
解决办法
9886
查看次数

如何允许引用类型参数的请求正文为空?

我正在构建一个 .Net Core api 控制器,我希望允许用户发送GET带有或不带有MyRequest类作为参数的请求,因此使用Get(null)例如调用方法将是好的。

GET api/myModels 请求方法:

[HttpGet]
public ActionResult<IEnumerable<MyModel>> Get(MyRequest myRequest)
{
    if (myRequest == null)
        myRequest = new myRequest();

    var result = this._myService.Get(myRequest.Filters, myRequest.IncludeProperties);
    return Ok(result);     
}
Run Code Online (Sandbox Code Playgroud)

MyRequest 班级:

public class MyRequest
{
    public IEnumerable<string> Filters { get; set; }
    public string IncludeProperties { get; set; }
}
Run Code Online (Sandbox Code Playgroud)

当我Get使用Postmanwith Body引用此方法时,它起作用了。问题是,当我将主体保持为空时(以MyRequestnull 对象作为参数调用 Get 方法,例如Get(null)),我得到了以下Postman信息:

“需要一个非空的请求正文。”

有一个类似的问题,但那里的参数是值类型。

c# get postman .net-core

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

“MaxAutoRenewDuration”在azure service bus中的作用是什么?

我正在使用Microsoft.Azure.ServiceBus. (文档)

我得到了一个例外:

提供的锁无效。锁已过期,或者消息已从队列中删除。

通过这些问题的帮助:

1 , 2 , 3 ,

我可以Exception通过设置AutoCompletetofalse和将 Azure 的队列锁定持续时间增加到最大值(从 30 秒到 5 分钟)来避免这种情况。

_queueClient.RegisterMessageHandler(ProcessMessagesAsync, new 
                         MessageHandlerOptions(ExceptionReceivedHandler)
                         {
                             MaxConcurrentCalls = 1,
                             MaxAutoRenewDuration = TimeSpan.FromSeconds(10),
                             AutoComplete = false
                         }
);

private async Task ProcessMessagesAsync(Message message, CancellationToken token)
{
    await ProccesMessage(message);
}

private async Task ProccesMessage(Message message)
{
    //The complete should be closed before long-timed process
    await _queueClient.CompleteAsync(message.SystemProperties.LockToken);
    await DoFoo(message.Body); //some long running process
}
Run Code Online (Sandbox Code Playgroud)

我的问题是:

c# azure azureservicebus .net-core

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

执行 DbCommand 失败,因为超时已过期 .net 核心

我的目标是提供简单的 API 来从Payments包含 5 列的(~400 行)表中检索数据。

Payment: Id (int),
PaymentsNumber (tinyint),
Rate (decimal(18,2)),
ProductType (tinyint),
ClientClubType (tinyint).
Run Code Online (Sandbox Code Playgroud)

用户可以使用请求参数(应返回约 12 行)来发出帖子请求:

PaymentsRequest 
{
    public int? PaymentsNumber { get; set; }
    public byte? ProductType { get; set; }
    public byte? ClientClubType { get; set; }
}
Run Code Online (Sandbox Code Playgroud)

使用 EF 核心:

services.AddDbContext<MyContext>(cfg => cfg.UseSqlServer(Configuration.GetConnectionString(...),optionsBuilder => optionsBuilder.CommandTimeout(60)));

public async Task<IEnumerable<Payments>> GetPaymentsAsync(PaymentsRequest request)
{
    IQueryable<Payments> query = this._context.Set<Payments>();
    query = query.Where(filter => 
                        (request.ClientClubType == null || filter.ClientClubType == request.ClientClubType) &&
                        (request.ProductType == null || …
Run Code Online (Sandbox Code Playgroud)

c# sql-server azure entity-framework-core .net-core

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

源有 X 个元素,但目标只允许 1 个

打字稿编译显示此错误:

源有 X 个元素,但目标只允许 1 个。

export const FooMapping: [{id: FooOperation, display: string}] = [
    { id: FooOperation.Undefined, display: 'Nothing' },
    { id: FooOperation.A, display: 'I'm A' },
    { id: FooOperation.B, display: 'I'm B' }
];

export enum FooOperation {
    Undefined = 0,
    A = 1,
    B = 2,
}
Run Code Online (Sandbox Code Playgroud)

定义特殊对象数组的正确方法是{id: FooOperation, display: string}什么?

typescript angular

7
推荐指数
2
解决办法
6574
查看次数

IDictionary如何在删除时获取已删除的项值

我想知道是否可以IDictionary通过其键删除项目,同时获取已删除的实际值?

就像是:

Dictionary<string,string> myDic = new Dictionary<string,string>();
myDic["key1"] = "value1";

string removed;
if (nameValues.Remove("key1", out removed)) //No overload for this...
{
    Console.WriteLine($"We have just remove {removed}");
}
Run Code Online (Sandbox Code Playgroud)

产量

//We have just remove value1
Run Code Online (Sandbox Code Playgroud)

c# idictionary

6
推荐指数
2
解决办法
129
查看次数