Ticket T148956
Visible to All Users

get Data from SQLServer with Stored Procedures

created 10 years ago

HI,

we have a SQL server database with 200 tabels, now we will  build an application with xaf for this tabels.
can i use xaf ORM Data Model with stored procedues for read /update or must i  use EF6 and stored procedures?
We will take procedures  for performance an we must have some filters for the data inside this databasecode (user/time/aerea and so on).

Please can you give me a compleate example for the best solution.

Kind regards

martin

Answers approved by DevExpress Support

created 10 years ago

Hello Martin,

Thank you for your interest in our tools for developers.
eXpressApp Framework (XAF) framework is based on XPO and Entity Framework, which are ORM. The ORM concept is very important here as in our framework you should not normally think of database tables, stored procedures, SQL statements, but rather operate data in an object-oriented manner.
I suggest you check out the Business Classes vs Database Tables help article to get more inspirations. Some links about Domain Driven Design posted in the http://community.devexpress.com/blogs/eaf/archive/2008/05/20/xaf-1-best-practices-for-domain-objects.aspx blog post may be helpful as well.
As you might distill from this, the core of our framework is a business or domain object, and not a database table or SP. Thus, most of XAF scenarios are implemented considering that you are dealing with business objects. Yes, there is certainly support for executing a raw SQL via the Session.ExecuteXXX method, stored procedures, mapping to database views at the XPO level, but there is no specialized support in XAF for this, as such cases are considered to be exceptions rather than rules due to above.

If in your project you have to heavily work with stored procedures or read data from database views, I think that you would better avoid using XAF for your project and rather implement it the 'old way', just using our visual components and the standard means for accessing SQL data.
Alternatively, you can still use XAF, but try to start thinking its way and operating your requirements by business objects and not database tables. Take special note that you can easily establish relationships between your objects and XPO will manage all the data retrieval tasks for you (like joining multiple tables). I suggest you check out the Object Relationships help article to get started with this. Most likely, it will be easier for you if XPO creates all the associated objects using the ORM Data Model Wizard or using the designer provided by EF.
As for filtering data, the object-oriented criteria language or LINQ is always at your service with our frameworks: Querying a Data Store
Technically, it is possible to create persistent business objects mapped to the database views with the help of INSTEAD OF triggers and stored procedures, but this is not that straightforward and may also be complicated since you have two hundred tables.

    Comments (2)

      Hi,
      thanks for this, but one more question.
      I must filter all Data for spezial conditions, me first idea was read the data with prozedures with include joins for conditions.
      But when i build this xaf Framework with Bussinesobjekts  i can not filter on the  Database layer.
      Tell me what is the best way to filter the Data before the user have access on it, we use SQL server 2012.
      Kind regards
      Martin

      Dennis Garavsky (DevExpress) 10 years ago

        If you opt to use XPO for data access in XAF, then you can use its application server or SecuredObjectSpaceProvider together with the remote IDataStore proxy (E4930) to hide the database from end-users, and also filter out sensitive data on the application server side and not on the client. In this configuration, filtering conditions will be expressed through the object oriented criteria language as part of security permissions provided as part of XAF's security module.
        Still, there is an option to filter out your data at the database level by creating database views and mapping persistent classes to them.
        I suggest you explore these two options while evaluating XAF for your project.

        Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

        Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.