Retreiving the data

2 posts, 0 answers
  1. giuseppe
    giuseppe avatar
    10 posts
    Member since:
    Nov 2010

    Posted 07 Feb 2011 Link to this post

    Hello

    I am actaully testing OA Orm together with asp.net controls making very basic things. Actually what is the fastest way to manually retreive the data after a query has been performed?
    As a matter of example:
    <telerik:OpenAccessDataSource ID="OpenAccessDataSource1" runat="server" 
        EnableDelete="False" EnableInsert="False" EnableUpdate="False" 
        ObjectContextProvider="TelerikTest.TelerikTestEntityDiagrams, TelerikTest" 
        TypeName="TelerikTest.User" 
        Where="Username == @Username AND Password == @Password">
        <WhereParameters>
            <asp:ControlParameter ControlID="username" Name="Username" 
                PropertyName="Text" />
            <asp:ControlParameter ControlID="password" Name="Password" 
                PropertyName="Text" />
        </WhereParameters>
    </telerik:OpenAccessDataSource>

    After the parameters are passwed I would like to:
    • Verify if record exists;
    • write a db value from the query in a label

    Any help would be appreciated.

    Giuseppe

  2. Petko_I
    Admin
    Petko_I avatar
    184 posts

    Posted 11 Feb 2011 Link to this post

    Hello giuseppe,

    We apologize for the late response. We are happy to know you are evaluating the functionality of OpenAccess. We would like to elaborate more on the use of the OpenAccessDataSource. The main responsibility of the OpenAccessDataSource is to make the loading of data transparent so that a common set of tasks performed during the interaction with UI controls bound to the data source are automated. The OpenAccessDataSource provides a layer of abstraction over the loading of the data and does not offer a direct way to access individual items from the result set. In order to do that you can use the functionality of the UI control which exposes its collection of Items. The individual items you will directly retrieve (by accessing the Items collection of the RadGrid for example) are wrappers whose data bound objects corresponds to the actual objects that are persisted and loaded by the OpenAccessDataSource. So, the OpenAccessDataSource fits quite well in a scenario where your query will retrieve many items in the common case and those items will be displayed in a UI control. If you would like to verify if there is a record in the database based on supplied parameters the recommended approach would be to use a LINQ query. In your case you would like to see whether there already is a user with the given combination of a user name and a password. Since you will not be displaying the users returned from the OpenAccessDataSource you can just use a LINQ query which checks if the count of items returned is 0.

    We have a set of basic examples available with our OpenAccess SDK browser which are related to the use of the OpenAccessDataSource. If you had not looked at them already, they may prove quite useful. Furthermore, we have a rich set of ASP examples which exemplify alternatives to the loading of persistent objects which use the OnNeedDataSource event of the UI controls to dynamically bind a query result set. This alternative to the OpenAccessDataSource is beneficial in the case of a highly customized result set. We would like to mention we also provide a comprehensive Sofia Car Rental ASP integration example which is also accessible through the OpenAccess SDK browser.

    Do not hesitate to contact us if you have further questions.

    Greetings,
    Petko_I
    the Telerik team
    Accelerate your learning with industry's first Telerik OpenAccess ORM SDK. Download today.
  3. DevCraft banner
Back to Top