1

Closed

Incorrect number of arguments in Load method

description

I have a reference to previous Email (email1 in attachment), which is identified by 3 values.
Load method is created with 3 parameters but called only with 1 (id).

file attachments

Closed Feb 7, 2008 at 6:26 PM by ld9474
This is not an issue as the database model is not normalized.

comments

ld9474 wrote Feb 3, 2008 at 11:33 PM

What is the Primary Key of the underlying Database. The generation process, generates a static load with primary key columns as parameters. As i read the generated code, the primary key is composed of an IdReservation, a date and a direction. Is this correct?
On the other hand you seem to reference a parent mail with a technical id which is not the primary key of the table. Is that also correct?
If my supposition aren't right could you give me the structure of your table?
Thanks very much.

kloken wrote Feb 4, 2008 at 8:15 PM

Sorry for not having described the DB correctly. Yes, exactly. Primary Key is IdReservation, date and a direction. It is because of integrity (probably not the best solution) and parent is a unique id (but not primary) for fast access. The error is, that the (static) Load method is declared with the whole primary key (so 3 parameters) but the Load method is called with only one parameter (once unique idEmail and once idReservation). IdEmail is OK but there is not a corresponding static method and idReservation call is incorrect because 2 parameters are missing.

ld9474 wrote Feb 5, 2008 at 6:51 PM

I see your problem but how a robot guess such things? It only sees that there is a primary key and foreign keys and based on that generates code. Do you have a generic rule that can answer your problem? Otherwise you can write your specific code in the file not extended "generated.cs". This file is never overwritten by the generation process.
Does it solve it?

kloken wrote Feb 5, 2008 at 7:29 PM

Yes, that is the easiest solution. I was just surprised when the generated code included errors.

wrote Feb 7, 2008 at 6:26 PM

ld9474 wrote Feb 8, 2008 at 9:30 PM

The next version will include a module that will get existing (user made) stored procedures for a database. Thinking about it, i thought it would be nice that a user chose the DAL method, that will be called to fill an object. This could solve the problem you mentionned. I'm working on it (at least for the Stored Procedure module for now).
Thanks for the idea ;)

wrote Feb 13, 2013 at 6:35 PM

wrote May 15, 2013 at 2:48 AM