Does OpenAccess make CRUD SPs?

4 posts, 0 answers
  1. G S S
    G S S avatar
    85 posts
    Member since:
    Mar 2008

    Posted 10 Jan 2010 Link to this post

    Hi,

    I have OpenAcces Orm (trial) and I am planning on generating the class library for all of my tables soon.

    This may sound a little naive, but does OpenAcces ORM make CRUD SPs in my SQL Server database?

    Also, can I write code like this to query data?: http://www.entityspaces.net/Portal/Default.aspx

    Thanks
  2. Alexander
    Admin
    Alexander avatar
    727 posts

    Posted 11 Jan 2010 Link to this post

    Hi G S S,

    By default stored procedures are not generated and dynamic SQL is used for each operation. However, you can force OpenAccess to create and use stored procedures instead of dynamic SQL for write operations. More details on how to achieve this could be found in this article. Already existing stored procedures can be used as well as described in this article.

    Regarding your second question, yes, it is possible to use Linq to query data. Here is a simple comparison between all available methods for retrieving data - Linq, OQL and SQL. More Linq samples can be found in our Linq C# Examples application which is automatically installed with the product. Hope that helps.

    Best wishes,
    Alexander
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. DevCraft banner
  4. Dan
    Dan avatar
    70 posts
    Member since:
    Mar 2007

    Posted 20 Nov 2011 Link to this post

    Hi

    I'm using SPs & Views as much as I can in my applications and almost all of them, CUD, return a value which represents a code that can acknowledge the application about different causes/reasons if SP command failed; please see this example:

    /*******************************************
        Portal_DeleteUser
    ********************************************/
    IF NOT EXISTS (SELECT NAME FROM sys.objects WHERE TYPE = 'P' AND NAME = 'Portal_DeleteUser')
    BEGIN
        EXEC('CREATE PROCEDURE [Portal_DeleteUser] AS RETURN')
    END
     
    GO
     
    ALTER PROCEDURE [Portal_DeleteUser]
         @id uniqueidentifier,
         @recordVersion timestamp = NULL
    AS
    BEGIN
        DECLARE @ReturnCode smallint
        SET @ReturnCode = 0
         
        SET NOCOUNT ON
         
        BEGIN TRY
            DELETE FROM [Portal_Users]
            WHERE ([Id] = @id) AND
                ([RecordVersion] = CASE WHEN @recordVersion IS NULL THEN [RecordVersion] ELSE @recordVersion END)
            IF @@ROWCOUNT = 0
                SET @ReturnCode = -1
            ELSE
                BEGIN
                    SET @ReturnCode = 1            
                    DELETE FROM [Portal_UserContactDetails] WHERE
                        ([UserId] = @id)
                    --DELETE FROM [Portal_B2BBankAccounts] WHERE
                    --  ([PartnerId] = @id)
                    --COMMIT TRANSACTION PartnerDelete;
                END
        END TRY
     
        BEGIN CATCH
            IF ERROR_NUMBER() = 547
                SET @ReturnCode = -2
            ELSE
                BEGIN
                    SET NOCOUNT OFF;
                    EXEC RethrowError;
                END
        END CATCH  
         
        SET NOCOUNT OFF
         
        RETURN @ReturnCode
    END
     
    GO


    It will be great for me to have control on names & content of CUD SPs. One good reasons is because we have large applications already in production and any attempt to make changes could cause unpleasant events or generates supplementary costs on updates.

    We would appreciate if we could have more flexibility on these issues.

    I have for few years this component, but I hesitate to use it because of the above reasons.
    Thank you your time.

    Regards
    Dan
  5. Damyan Bogoev
    Admin
    Damyan Bogoev avatar
    581 posts

    Posted 22 Nov 2011 Link to this post

    Hello Dan,

    1. Using custom naming strategies for the CUD procedures names is on our to-do list. We will implement this feature in the future.
    2. You could use the ADO API of the product to execute stored procedures within your application. 
    Helpful examples how to use the ADO API can found in the Product SDK.
    Hope that helps.

    All the best,
    Damyan Bogoev
    the Telerik team

    NEW and UPDATED OpenAccess ORM Resources. Check them out!

Back to Top