C# 如何将活动方法中从SQL数据库检索到的数据连接到luis intent,并使用luis intent显示数据

C# 如何将活动方法中从SQL数据库检索到的数据连接到luis intent,并使用luis intent显示数据,c#,sql,botframework,azure-language-understanding,C#,Sql,Botframework,Azure Language Understanding,我想将从活动方法中的SQL数据库检索到的数据连接到luis intent,并使用luis intent显示数据。在SimpleLUISDialog.cs中输入Luis intent中的话语存储后,我应该在我的Luis intent中添加什么来显示数据库中的数据 MessagesController.cs中的活动方法由MessagesController定义。我是否需要更改activity方法中的代码以适应Luisint的工作?wait context.PostAsync($“”);在luis中,

我想将从活动方法中的SQL数据库检索到的数据连接到luis intent,并使用luis intent显示数据。在SimpleLUISDialog.cs中输入Luis intent中的话语存储后,我应该在我的Luis intent中添加什么来显示数据库中的数据

MessagesController.cs中的活动方法由MessagesController定义。我是否需要更改activity方法中的代码以适应Luisint的工作?wait context.PostAsync($“”);在luis中,需要替换意图,因为我需要从sql数据库获取响应。因此,我需要将ShowCutOffPoint方法调用到luis意图中。 多谢各位

这是SimpleLUISDialog.cs中的活动方法

  private async Task ShowCutOffPoint(IDialogContext context, 
  IMessageActivity msg, Activity activity)
    {
        // This method will take an Activity and return a response
        // that will conatin the current High Scores

        // Connect to the database
        Models.BotDataEntities2 DB = new Models.BotDataEntities2();



        var text = activity.Text;
        if (!Int32.TryParse(text, out int number))
        {
            //reply that there is no number;
            return;
        }
        // Get the top 5 high scores since yesterday
        var Courses = (from UserLog in DB.NYPCourses
                       where (UserLog.Course != null) && (UserLog.CutOffPoint == number)
                       select UserLog)
            .OrderBy(x => x.Course)
            .ToList();

        // Create a response
        System.Text.StringBuilder sb = new System.Text.StringBuilder();

        sb.Append("Course Information:\n\n");

        // Loop through each high score
        foreach (var Course in Courses)
        {
            // Add the High Score to the response
            sb.Append(String.Format("School: {0}/ Course: {1}/ Course Code: {2}/ Cut Off Point: {3})\n\n"
                , Course.School
                , Course.Course
                , Course.CourseCode
                , Course.CutOffPoint));
        }


        await context.PostAsync(sb.ToString());
        context.Wait(this.MessageReceived);

    }
[LuisIntent("CutOffPoint")]
        public async Task CutOffPoint(IDialogContext context, IAwaitable<IMessageActivity> message, LuisResult result)
        {
        var msg = await message;
        await ShowCutOffPoint(msg);
        }
SimpleLUISDialog.cs中的Luis意图

  private async Task ShowCutOffPoint(IDialogContext context, 
  IMessageActivity msg, Activity activity)
    {
        // This method will take an Activity and return a response
        // that will conatin the current High Scores

        // Connect to the database
        Models.BotDataEntities2 DB = new Models.BotDataEntities2();



        var text = activity.Text;
        if (!Int32.TryParse(text, out int number))
        {
            //reply that there is no number;
            return;
        }
        // Get the top 5 high scores since yesterday
        var Courses = (from UserLog in DB.NYPCourses
                       where (UserLog.Course != null) && (UserLog.CutOffPoint == number)
                       select UserLog)
            .OrderBy(x => x.Course)
            .ToList();

        // Create a response
        System.Text.StringBuilder sb = new System.Text.StringBuilder();

        sb.Append("Course Information:\n\n");

        // Loop through each high score
        foreach (var Course in Courses)
        {
            // Add the High Score to the response
            sb.Append(String.Format("School: {0}/ Course: {1}/ Course Code: {2}/ Cut Off Point: {3})\n\n"
                , Course.School
                , Course.Course
                , Course.CourseCode
                , Course.CutOffPoint));
        }


        await context.PostAsync(sb.ToString());
        context.Wait(this.MessageReceived);

    }
[LuisIntent("CutOffPoint")]
        public async Task CutOffPoint(IDialogContext context, IAwaitable<IMessageActivity> message, LuisResult result)
        {
        var msg = await message;
        await ShowCutOffPoint(msg);
        }
[Luisint(“截止点”)]
公共异步任务截止点(IDialogContext上下文、IAwaitable消息、LuisResult结果)
{
var msg=等待消息;
等待显示截止点(msg);
}

只需将
ShowCutOffPoint
方法从
messagescocontroller
移动到
SimpleLUISDialog

然后更新
截止点
方法的签名,以包括活动:

[LuisIntent("CutOffPoint")]
public async Task CutOffPoint(IDialogContext context, IAwaitable<IMessageActivity> message, LuisResult result)
{
     var msg = await message;  
     await ShowCutOffPoint(msg) 
}


在context.PostAsync(sb.ToString())中突出显示上下文时出错;context.Wait(this.MessageReceived);如何在我的luis intentan wait中调用ShowCutOffPoint在context.postsync(sb.ToString())之前就不存在了;wait context.PostAsync($“”);在luis中,需要替换意图,因为我需要从sql数据库获取响应。因此,我需要将ShowCutOffPoint方法调用到luis意图中。谢谢实际上等待不需要添加,因为我忘了在方法中添加IDialogContext上下文。