c# - 无法隐式转换类型 C# .Net Core 问题
问题描述
我想要做的是使用.NET Core 制作一个 api 服务,我在其中从数据库制作一个数组.... ]'。
我是否朝着正确的方向前进?我正在尝试制作我的 Angular 客户端可以使用的 api 服务。
动作控制器
public class ActionsController : ControllerBase
{
private IActionService _actionService;
public ActionsController(IActionService actionService)
{
_actionService = actionService;
}
//GET: api/Actions
[HttpGet]
public IActionResult GetActions(string userId, string sessionId)
{
// TODO: Figure out when recurseOnMenus is true, pass it accordingly instead of forcing false.
DbrAction[] dbrActions = _actionService.GetActions(userId, sessionId);
return Ok(dbrActions);
}
行动服务
public interface IActionService
{
Action[] GetActions(string userId, string sessionId);
}
public class ActionService : IActionService
{
private DataContext _context;
public ActionService(DataContext context)
{
_context = context;
}
public DbrAction[] GetActions(string sessionId)
{
UserStateHelper ush = new UserStateHelper();
UserState us = ush.CreateUserState(sessionId);
XioTable xt = new XioTable(us, T.User);
DbrUser user = (DbrUser)xt.LoadSingleRow(us.UserTag, C.User_DefaultActionTag);
Actions[] actions = {};
List<DbrAction> dbrActions = new List<DbrAction>();
xt = new XioTable(us, T.Action);
xt.SelectCols(C.Action_Description, C.Action_ActionName, C.Action_FolderTag, C.Action_ActionType, C.Action_PrimaryTable);
xt.LoadData();
foreach (DbrAction action in xt.GetAllRows(C.Action_FolderTag))
{
if (!DbrAction.IsTableDeprecated(action.PrimaryTable))
{
if (action.ActionType == ActionType.View || action.ActionType == ActionType.Dashboard)
dbrActions.Add(action);
}
}
us.Completed(LogEntryType.GetStartupProfileData, null);
return dbrActions.ToArray();
}
public Action[] GetActions(string userId, string sessionId)
{
throw new NotImplementedException();
}
解决方案
推荐阅读
- javascript - 添加第 17 个 Mapbox 地图后,Slick 幻灯片失败
- javascript - 比较数组和对象的值,如果为真,则将它们保存到另一个对象
- google-apps-script - 有没有办法自动打印谷歌表格下拉菜单中的所有选项?
- linux - 将动态加载的二进制文件静态链接到二进制文件中
- java - 以下方法不存在:org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor.setProxyTargetClass(Z)V
- reactjs - 当我“添加到主屏幕”时,为什么我的应用程序不使用 manifest.json?
- javascript - 如何使用与jquery兼容的json格式制作下拉列表
- ios - UIViewController.storyboard 只能在主线程中使用 - 新错误我不知道如何修复?
- python - 使用QWebEngine登录SAML授权页面,等待cookie,然后清理/退出
- javascript - (Moodle) 导出包含 HighCharts 图像的 .xlsx 文件时,我不断获取原始数据