This is a migrated thread and some comments may be shown as answers.

Does OpenAccess make CRUD SPs?

3 Answers 133 Views
Getting Started
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
G S S
Top achievements
Rank 1
G S S asked on 10 Jan 2010, 05:38 PM
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

3 Answers, 1 is accepted

Sort by
0
Alexander
Telerik team
answered on 11 Jan 2010, 07:55 AM
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.
0
Michael
Top achievements
Rank 1
answered on 20 Nov 2011, 07:46 PM
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
0
Damyan Bogoev
Telerik team
answered on 22 Nov 2011, 03:25 PM
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!

Tags
Getting Started
Asked by
G S S
Top achievements
Rank 1
Answers by
Alexander
Telerik team
Michael
Top achievements
Rank 1
Damyan Bogoev
Telerik team
Share this question
or