build errors on my first use

Data Access Application Blocks Forum

build errors on my first use

Postby chenry on Thu Dec 01, 2005 2:38 pm

Hi, I would like to use EasyObject, but i can't even compile one generated file.

I've added EasyObject in my webSolution, I have generated several entities files with Mygeneration and added them to my Bll.
But no one of these files wants to compile.

I 've got these kind of errors:
\"The best overloaded method match for 'NCI.EasyObjects.SchemaItem.SchemaItem(string, System.Data.DbType, bool, bool, bool, bool, bool)' has some invalid arguments\"

and

\"c:\\inetpub\\wwwroot\\phf\\Bll\\_CoverLetter.cs(46): Argument '2': cannot convert from 'System.Data.SqlDbType' to 'System.Data.DbType'\"

refering to that kind of egnerated lines:
public static SchemaItem PhfID = new SchemaItem(\"PhfID\", SqlDbType.Int, false, false, false, true, true);


Did I miss anything ?

some few other questions:
-where is described the diffeerence between \"dooads proc format\" and \"asp.net Sarter kit proc format\" ?

-in the underlying code of easyObject, are the storedprocedure called with a collection of typed parameters (and not a string containing a concatenation of parameters) ?

-could you confirm that \"Sql DAAB stored procedures\" is the right template for useing with EasyObject ?

thanks a lot

Christophe
chenry
Staff Sergent
 
Posts: 38
Joined: Thu Dec 01, 2005 2:11 pm

Re: build errors on my first use

Postby mgnoonan on Thu Dec 01, 2005 3:11 pm

Hi Christophe,

First off, welcome! Stick with it, we'll get you up and running in no time! :)

chenry wrote:I 've got these kind of errors:
"The best overloaded method match for 'NCI.EasyObjects.SchemaItem.SchemaItem(string, System.Data.DbType, bool, bool, bool, bool, bool)' has some invalid arguments"

and

"c:\\inetpub\\wwwroot\\phf\\Bll\\_CoverLetter.cs(46): Argument '2': cannot convert from 'System.Data.SqlDbType' to 'System.Data.DbType'"

refering to that kind of egnerated lines:
public static SchemaItem PhfID = new SchemaItem("PhfID", SqlDbType.Int, false, false, false, true, true);

It sounds like you have the DbTarget in MyGeneration's Default Settings set to SqlClient. Change it to DbType instead. The Enterprise Library is database independent, so it does not use SqlClient in its external methods, only internally. That way you don't have to change your code if you decide to use Oracle, DB2, etc.

chenry wrote:-where is described the diffeerence between "dooads proc format" and "asp.net Sarter kit proc format" ?

The Starter Kit format is the default. If you are not migrating from dOOdads, there's no need to change it. More info can be found in this post:
http://www.mygenerationsoftware.com/phpbb3/viewtopic.php?t=1573

chenry wrote:-in the underlying code of easyObject, are the storedprocedure called with a collection of typed parameters (and not a string containing a concatenation of parameters) ?

All the generated queries are parameterized, so there is no danger of SQL injection attacks. Non-parameterized queries are supported but not encouraged. :wink:

chenry wrote:-could you confirm that "Sql DAAB stored procedures" is the right template for useing with EasyObject ?

Yep, you got it! I originally wrote those based on the Starter Kits, but they have evolved to support EasyObjects. I probably should rename the template because it confuses newcomers, but there is some history there I didn't want to mess with.

Please feel free to ask any questions, and we will try to keep you moving forward.
Matt Noonan
EasyObjects.NET - The O/RM for the Enterprise Library
http://www.easyobjects.net
User avatar
mgnoonan
Expert
 
Posts: 1019
Joined: Tue Sep 14, 2004 3:17 am
Location: Springboro, OH

Postby chenry on Thu Dec 01, 2005 3:34 pm

thanks a lot!!!
perfect answer :)
It solved that issue.

By the way, it seems that there is a problem of refresh in Mygeneration for the projects (since my defined project did not take in account the setting change of DBTarget).


Now i've got other issues with getbyte and setbyte.
But i think i've seen a post on that.
I 'm going to look for it.

Christophe
chenry
Staff Sergent
 
Posts: 38
Joined: Thu Dec 01, 2005 2:11 pm

Re:

Postby mgnoonan on Thu Dec 01, 2005 3:38 pm

chenry wrote:Now i've got other issues with getbyte and setbyte.
But i think i've seen a post on that.
I 'm going to look for it.

I thought those issues were resolved, so please let me know if they aren't. Make sure you have the latest version of the templates.
Matt Noonan
EasyObjects.NET - The O/RM for the Enterprise Library
http://www.easyobjects.net
User avatar
mgnoonan
Expert
 
Posts: 1019
Joined: Tue Sep 14, 2004 3:17 am
Location: Springboro, OH

Postby chenry on Thu Dec 01, 2005 3:49 pm

well i seems that these issues are still there.

I updated the template ( bu i think that i had alerady had the latest version), and it did not change anything.

Why would it be a problem in the template ?
I think, it is in the easyobject.cs, as you mentioned it in your last post on that issue.

I 'm using the last version, easyobject10, taken from your \"gold\" post...

Christophe
chenry
Staff Sergent
 
Posts: 38
Joined: Thu Dec 01, 2005 2:11 pm

Postby mgnoonan on Thu Dec 01, 2005 3:53 pm

Sometimes the C# templates do not capitalize properly, so a bug in the template might generate \"Getbyte\" instead of \"GetByte\", which is the actual method name.

Give me some more specifics about the problem you are having, and I will get you a fix.
Matt Noonan
EasyObjects.NET - The O/RM for the Enterprise Library
http://www.easyobjects.net
User avatar
mgnoonan
Expert
 
Posts: 1019
Joined: Tue Sep 14, 2004 3:17 am
Location: Springboro, OH

Postby chenry on Thu Dec 01, 2005 3:58 pm

you 're right on the origin
the capitalization is bad in my generated files
but i do not understand since i've juste updated the template ...

i'm going to try again...

Christophe
chenry
Staff Sergent
 
Posts: 38
Joined: Thu Dec 01, 2005 2:11 pm

Postby chenry on Thu Dec 01, 2005 4:08 pm

well, after several runs,
either I 'm not abble to do a correct update in MyGeneration, or the latest template is wrong, because I never get \"GetByte\" (only \"Getbyte\")


Christophe
chenry
Staff Sergent
 
Posts: 38
Joined: Thu Dec 01, 2005 2:11 pm

Postby mgnoonan on Thu Dec 01, 2005 4:10 pm

I just tried my copy of the template on the Northwind Employees table, which has a Photo column with a datatype of Image.

My EasyObject C# Business Entity correctly generates and compiles. Also of note, it generated GetByteArray/SetByteArray, not GetByte/SetByte.

If you did the web update in MyGeneration, try closing the template and reopening it to make sure you have the fresh copy loaded.

Can you post a CREATE TABLE script so I can try it out?
Matt Noonan
EasyObjects.NET - The O/RM for the Enterprise Library
http://www.easyobjects.net
User avatar
mgnoonan
Expert
 
Posts: 1019
Joined: Tue Sep 14, 2004 3:17 am
Location: Springboro, OH

Postby chenry on Thu Dec 01, 2005 4:20 pm

CREATE TABLE [dbo].[Civil] (
[CivilID] [tinyint] NOT NULL ,
[CivilEN] [varchar] (20) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[CivilFR] [varchar] (20) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[CivilES] [varchar] (20) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
) ON [PRIMARY]


by the way, on the template, on line 22, it's written :
' Last Update : 11/30/2005

is the right last version ?

Christophe
chenry
Staff Sergent
 
Posts: 38
Joined: Thu Dec 01, 2005 2:11 pm

Postby mgnoonan on Thu Dec 01, 2005 4:32 pm

Yes. that is the right version. Unfortunately, you did find a bug in the template (could have sworn I fixed this one).

Do a web update on the template, close and reopen it and you should be good to go.

One observation, you realize you need a primary key on your table in order for EO to generate properly. I assumed it was the CivilID for the purposes of this test.
Matt Noonan
EasyObjects.NET - The O/RM for the Enterprise Library
http://www.easyobjects.net
User avatar
mgnoonan
Expert
 
Posts: 1019
Joined: Tue Sep 14, 2004 3:17 am
Location: Springboro, OH

Postby chenry on Thu Dec 01, 2005 4:49 pm

well, you made me noticed, that i've forgotten to set \"IDENTITY\" columns in my VISIO chart, before running geration of the sql Database.

About the Key, yeah, it was civilID
Well it was the sql script generated by SQL Manager.
Quite strange...
Here is the same with SQL Query Analyser:
CREATE TABLE [Civil] (
[CivilID] [tinyint] IDENTITY (1, 1) NOT NULL ,
[CivilEN] [varchar] (20) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[CivilFR] [varchar] (20) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[CivilES] [varchar] (20) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
CONSTRAINT [Civil_PK] PRIMARY KEY CLUSTERED
(
[CivilID]
) ON [PRIMARY]
) ON [PRIMARY]


If I understand what you told me, I musn't generate Entities for Tables which have no Primary Key ?

Now I'm going to try the new update

Christophe
chenry
Staff Sergent
 
Posts: 38
Joined: Thu Dec 01, 2005 2:11 pm

Postby chenry on Thu Dec 01, 2005 4:52 pm

no more errors with the new template

thanks a lot!!

Christophe
chenry
Staff Sergent
 
Posts: 38
Joined: Thu Dec 01, 2005 2:11 pm

Re:

Postby mgnoonan on Thu Dec 01, 2005 4:56 pm

chenry wrote:If I understand what you told me, I musn't generate Entities for Tables which have no Primary Key ?

Not exactly, so let me be clear here (and this is true for dOOdads as well). If you don't define a primary key for a table, then the LoadByPrimaryKey function will have no parameters and ultimately it will fail if you try to call it (assuming it even compiles).

Also, the Delete, Update and Insert functions have no way of determining what row you are trying to update if there is no primary key. So this is a fact of life when you are using EO: you must have a primary key defined if you want to do data updates.

However, you can still generate business objects based on Views which have no primary key, because the view template does not generate the data update logic (views are considered read-only). So if you have a table you cannot define a primary key for, and you have no need for update operations, just create a view for it and generate the business object using the EasyObject Business View template.
Matt Noonan
EasyObjects.NET - The O/RM for the Enterprise Library
http://www.easyobjects.net
User avatar
mgnoonan
Expert
 
Posts: 1019
Joined: Tue Sep 14, 2004 3:17 am
Location: Springboro, OH

Postby chenry on Thu Dec 01, 2005 5:02 pm

ok fine
thanks for all your explanations and your help

Christophe
chenry
Staff Sergent
 
Posts: 38
Joined: Thu Dec 01, 2005 2:11 pm

Postby mgnoonan on Thu Dec 01, 2005 5:18 pm

No problem. Keep me posted on how your project is going with EO. 8)
Matt Noonan
EasyObjects.NET - The O/RM for the Enterprise Library
http://www.easyobjects.net
User avatar
mgnoonan
Expert
 
Posts: 1019
Joined: Tue Sep 14, 2004 3:17 am
Location: Springboro, OH

Postby mike.griffin on Thu Dec 01, 2005 5:25 pm

Now if that isn't top notch support I don't know what is. Great job Matt. And thanks chenry for sticking with it and helping out. This is the kind of teamwork that makes it better for everyone.
User avatar
mike.griffin
Site Admin
 
Posts: 3290
Joined: Sat Apr 03, 2004 6:10 am
Location: Indianapolis, IN

Postby chenry on Thu Dec 01, 2005 5:46 pm

thanks to both of you, for giving us such good products!

Christophe
chenry
Staff Sergent
 
Posts: 38
Joined: Thu Dec 01, 2005 2:11 pm


Return to EasyObjects.NET (Microsoft Enterprise Library)

Who is online

Users browsing this forum: Google [Bot] and 0 guests

cron