Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QUESTION: How to use DNN DAL 2 to access data #42

Open
kingjordan opened this issue Jan 15, 2025 · 3 comments
Open

QUESTION: How to use DNN DAL 2 to access data #42

kingjordan opened this issue Jan 15, 2025 · 3 comments

Comments

@kingjordan
Copy link

Hello,

I have installed this app and am very excited about the live/staging/ and local connections which allow for real time development through hot reloading.

My question has to do with accessing DNN's DAL2 data access. In the past I have developed some angular modules for DNN where I use DAL2 for database access etc but I was unable to get live reloading working with angular. I want to update these modules to use your template, but my modules are compiled to the bin folder like traditional modules, and I can see that this one is not. So I have a number of C# services, controllers, entities, classes etc that hold the business logic for my module. Is there a way to bring this into the 2sic angular app?

Also, I have a number of predefined tables and views in the database that I don't want to convert into 2sic content. I'd like to access these as they are because there is a lot of historical data for clients in these tables. Is this possible?

Sorry to ask this as an issue

thanks

jordan

@iJungleboy
Copy link
Contributor

hi there @kingjordan

What you're asking for is absolutely no problem. 2sxc allows you to do anything you want, include what you describe above.

  1. Accessing your own services in DLLs - they are just as available in 2sxc as they would be in any other c# code
    1. so you can either create 2sxc WebApi endpoints to expose data to Angular
    2. or create your own endpoints in your DLL and just access them from Angular
  2. DB: Here you have all the possibilities you want
    1. create your own endpoints in the DLL doing whatever you want
    2. create endpoints in 2sxc doing SQL access using POCO or EF or whatever
    3. use VisualQuery and the SQL DataSource (this would be for read-only access)

So all no problem. Good luck! 🍀

@kingjordan
Copy link
Author

Hello Daniel,

thanks for the follow up, just one last question. Assuming I have a separate module that exposes api endpoints like:

http://dnndev.me/desktopmodules/myModule/api/item/getlist

how would I access that from within the 2sic angular app?

the current way to access simple controller from within the 2sic app is:

    this.nameMessage$ = simple.get<string>(
      'hello',
      new HttpParams().set('name', 'Michael')
    );

which results in a network call to:

http://dnndev.me/api/2sxc/app/auto/live/api/simple/hello

is there a built in way to access other DNN api's from other modules or will I have to create my own interceptors to add the headers/auth for those external api calls? Or can I use the built in 2sic way?

I hope that makes sense

Cheers

@iJungleboy
Copy link
Contributor

So 2sxc is only responsible for 2sxc APIs.

To use DNN Apis, you should just use fetch().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants