8/18/2025 1:27:27 AM
|
|
slxdeveloper.com Community Forums |
|
|
|
The Forums on slxdeveloper.com are now retired. The forum archive will remain available for the time being. Thank you for your participation on slxdeveloper.com!
Forum to discuss the use of the SalesLogix Web Platform, Client and Customer Portals, and the Application Architect (For version 7.2 and higher only). View the code of conduct for posting guidelines.
|
|
|
|
How to expose data from SQL view?
Posted: 19 Apr 09 10:26 PM
|
Hi all,
In a previous post (http://www.slxdeveloper.com/forum.aspx?forumid=4002&postid=21962) I asked several questions regarding how to implement a custom library (dll) that is going to be consumed from the web client. Since that post had too many questions I'm narrowing down to specific questions now.
So, I have to implement a custom library (dll) in VS (C#) that will be instantiated and consumed from the web client. This library will expose data that comes from several SQL views.
For instance, lets say I have an Account_Activity_Summary view, and I have to expose a method that queries this view for a given accountid in a given period. The data retrieved will be displayed in Web Client somehow (I haven't got to that part yet).
So, let's imagine I have something like void getActivitySummary(Account, Period, out Summary). I wonder what's the best way of doing this.
- What kind of parameter should I pass as Account? Does it have to be an IAccount, or would a string for AccountId suffice? - As for the return object (Summary) can just I return a DataSet or DataTable to be bound to controls on the web client, or do I have to return an IList or an EntitySet or something else? - Can I create an Entity for each of my views? So far, I've been told this cannot be done for SQL Views.
I guess what I'm asking is...if YOU had to do this, how would you implement this?
Thanks a lot. |
|
|
|
Re: How to expose data from SQL view?
Posted: 20 Apr 09 5:08 AM
|
Hi,
Firstly, can you use Saleslogix, its Interfaces and HQL to get the data you are after? I would interested as to what your views do to see if its will be possible to achieve the results in HQL. If so then you can create Business Rules against the appropriate entity to return the data. (You can also use SQL in the business rules to return the data should that be necessary, converting your result set into an IList at the end.)
That aside, to answer a couple of your questions:
- What kind of parameter should I pass as Account? Does it have to be an IAccount, or would a string for AccountId suffice?
Whatever you require - if you are using sql and view there is little point passing the Account interface, just pass the Account.Id.ToString();
- As for the return object (Summary) can just I return a DataSet or DataTable to be bound to controls on the web client, or do I have to return an IList or an EntitySet or something else?
I would return IList - this way the result can directly be bound to a gridview should you require. You can also manipulate the iList however you wish if you need to display the data differently.
- - Can I create an Entity for each of my views? So far, I've been told this cannot be done for SQL Views.
No you cannot, out of the box anyway. SLX only shows tables in the list of objects that you can create Entities from. Whether or not you can create an Interface from a View outside of SLX I do not know. If you can then it may be possible to add the record of the view to SecTableDefs and then you would have the table in the list that SLX shows you as available to create an Entity Interface from. I wouldnt bother with any of that though. You will probably break something and there is no way that would be supported.
By the sounds of it, you do not need an external library (dll) to do what you are after....
Thanks, Nick |
|
|
|
Re: How to expose data from SQL view?
Posted: 20 Apr 09 9:37 AM
|
Hi Nick, I want to thank you for your kind help on both of my posts.
The views have some complex data calculations that I think would be very difficult to implement otherwise, and since they are readily available, its of utmost importance to reuse them instead of coding new logic. The need for an external library (dll) is a customer requirement, not necessarily something that comes from the functionality to implement.
- How would you go about converting a result set to an IList? What kind of objects should this IList hold? - I wonder why I cannot create entities for views? Something related to NHibernate? I mean, as far as the DB administrator goes, I can add a view to SalesLogix table catalog, and use it just like the other tables, so I wonder why they can't be used within application architect to create entities. |
|
|
|
Re: How to expose data from SQL view?
Posted: 20 Apr 09 10:19 AM
|
Hi,
Thats understandable enough I guess!
- How would you go about converting a result set to an IList? What kind of objects should this IList hold?
I dont know how many records we are talking about in your circumstance, in fact I dont even know what data you need to return? Where do you need to see it? How does it relate to the current entity? It may be worth posting a touch more detail, but as a pointer if you have a list of Ids, you can create an entity interface and add it to the IList. For example:
//Sage.Entity.Interfaces.IAccount acc = Sage.Platform.EntityFactory.GetById(yourId);
You can now add this to the list. Obviously you would be using this in some sort of loop. Unfortunately I dont know of the overheads of doing this and whether its very efficient. It doesnt look like it is to be honest! If there are lots of rows it may be necessary to think of a different way. Let me know a bit more about the detail of what you want to achieve and I will have a think about it.
- I wonder why I cannot create entities for views? Something related to NHibernate? Nothing to do with NHibernate, you can have views. Its probably the SLX team didnt want to support views as the build process is currently uniform, i.e. we know all entities need to be update/insert/select/delete. It would be a lot more work to be "view aware" and set the necessary properties for this (ie. do not create the update/insert/delete mappings, and disable the user from having access to the rules. That said, I havent persevered with trying to use views, maybe you can. Doubt it though.. |
|
|
|
You can
subscribe to receive a daily forum digest in your
user profile. View the site code
of conduct for posting guidelines.
Forum RSS Feed - Subscribe to the forum RSS feed to keep on top of the latest forum activity!
|
|
|
|
|
|
|
|