小编Sha*_*dam的帖子

使用 EF core 2.1 调用 DbFunction

我尝试调用存储在数据库中的标量函数。这是我的代码:

public class PronosticDbContext : DbContext
{
    public PronosticDbContext(DbContextOptions<PronosticDbContext> options) : base(options)
    {

    }

    [DbFunction(FunctionName = "GetPlayerPointsForDay", Schema = "dbo")]
    public static int GetPlayerPointsForDay(int dayId, int userId) => throw new NotSupportedException();    
}
Run Code Online (Sandbox Code Playgroud)

电话:

private IQueryable<PlayerRankingData> GetPlayerRanking(int? dayId)
{
    return Context.Days.Where(x => x.Id == dayId.Value).Select(x => new PlayerRankingData
    {
        // Some properties
        Users = x.Season.Users.Select(us => new PlayerRankingData.User
        {
            // Other properties
            Last = PronosticDbContext.GetPlayerPointsForDay(x.Id, us.User.Id),
            // Others again
        }).OrderByDescending(u => u.Points).ThenByDescending(u => u.Last).ThenBy(u => u.Login)
    });
}
Run Code Online (Sandbox Code Playgroud)

我不明白为什么,但我总是去NotSupportedException,我的标量函数从未被调用。为什么我错过了? …

c# dbfunctions ef-core-2.1

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

javascript中的布尔值

好的,我有一个我不明白的问题.

我有一个布尔值,我测试,如果true我做了什么.但即使var是,javascript也永远不会进入true.

我试试这个:

if(isConfigD)
    handleConfigurationD;
Run Code Online (Sandbox Code Playgroud)

这个 :

if(isConfigD == true)
    handleConfigurationD;
Run Code Online (Sandbox Code Playgroud)

还有这个 :

if(isConfigD === true)
    handleConfigurationD;
Run Code Online (Sandbox Code Playgroud)

但没有任何工作,而isConfigD总是设置true:(

我错过了什么?

javascript

-4
推荐指数
1
解决办法
41
查看次数

标签 统计

c# ×1

dbfunctions ×1

ef-core-2.1 ×1

javascript ×1