Visual Studio LightSwitch - 如何从代码运行应用程序启动查询?
我有一个包含与用户安全相关的表的数据库,并将该数据库导入到 LightSwitch 中名为 UserData 的数据源中。 然后,我添加了对实体之一(角色实体)的查询 - GetRolesByPersonId(int)。我看到该查询是作为 UserData 类的非静态方法生成的,为了调用它,我当然需要该类的一个实例。
我想在我的应用程序启动时运行此查询以获取与安全相关的信息,以便启用/禁用菜单。
问题 1:我应该从什么方法/事件读取查询?我尝试从 Application_Initialize() 尝试,我是否正确?
问题2:在Application_Initialize()时是否有现成的UserData实例?我是否需要实例化一个新对象才能调用我的查询?
谢谢
I have a database containing tables related to user security and I imported this database into LightSwitch into a data source called UserData.
I've then added a query off one of the entities (Role entity) - GetRolesByPersonId(int). I see that this query is generated as a non-static method of the UserData class, and, in order to call it, I of course need an instance of this class.
I would like to run this query as my application starts up to get security-related information in order to enable/disable menus.
Question 1: From what method/event should I read the query? I trying from Application_Initialize(), am I correct?
Question 2: Is there a ready-to-use instance of UserData at the time of Application_Initialize()? Do I need to instanciate a new object in order to call my query?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为您可以在
Application_Initialize()
中使用Me.CreateDataWorkspace.ApplicationData
。I think you can use
Me.CreateDataWorkspace.ApplicationData
in theApplication_Initialize()
.