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

Column Sharing and Stored Procedures

2 Answers 76 Views
Databases and Data Types
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Pål
Top achievements
Rank 1
Pål asked on 04 Mar 2009, 03:13 PM
Hi.

I have three PC classes using flat inheritance strategy (shared table):

public class Principal {
    public string Name {get; set;}
}

public class BuiltinAccount : Principal {
    public AccountType BuiltinType {get; set;}
}

public class BuiltinRole : Principal {
    public RoleType BuiltinType {get; set;}
}

The two derived classes share the column "BuiltinType" for their properties "BuiltinAccount" and "BuiltinRole" which works fine, until I try to use stored procedures.

When building database, I get the following exception when creating stored procedure for the base class:

The variable name '@BuiltinType' has already been declared. Variable names must be unique within a query batch or stored procedure.

I guess this has to do with the fact that all columns in the table will be initialized either with a value or null, and since two derived classes reports the need of @BuiltinType column, they will be added twice.

Is this something you can fix, e.g. by performing a check if column already exists, and if so not add it again. It does work fine when not using stored procedures.

Best regards

Pål

2 Answers, 1 is accepted

Sort by
0
Pål
Top achievements
Rank 1
answered on 05 Mar 2009, 12:51 PM
Hi again. Have created a test project with the forementioned classes which replicates the problem.

If you send me an email-address to mine, i'll ship the solution to you.

Ragards

Pål
0
Jan Blessenohl
Telerik team
answered on 06 Mar 2009, 09:26 AM
Hi Pål,
That sounds good, thanks.

Please open a support ticket and attach the example as zip file there.

Regards,
Jan Blessenohl
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Databases and Data Types
Asked by
Pål
Top achievements
Rank 1
Answers by
Pål
Top achievements
Rank 1
Jan Blessenohl
Telerik team
Share this question
or