开发者

Visual Studio LightSwitch - How to run query on Application start-up from code?

开发者 https://www.devze.com 2023-04-02 18:16 出处:网络
I have a database containing tables related to user security and I imported this database into LightSwitch into a data source called 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 开发者_如何学Goinstance of UserData at the time of Application_Initialize()? Do I need to instanciate a new object in order to call my query?

Thanks


I think you can use Me.CreateDataWorkspace.ApplicationData in the Application_Initialize().

0

精彩评论

暂无评论...
验证码 换一张
取 消