can some one help me out

Posts   
 
    
KastroNYC
User
Posts: 96
Joined: 23-Jan-2006
# Posted on: 04-Feb-2006 02:10:48   

I've heard nothing but good things about LLBLgen and I'd love to use it but I've got less than 10 days left on my free trial and I can't seem to figure out how to get this to work. I'm getting sql errors like cannot insert null value into PK field. My db looks kinda like this:

ContactInfo

InfoID PK guid FirstName LastName

Telephone

TelephoneID PK int

ContactInfoTelephones (lookup table)

InfoID TelephoneID

Employee

EmployeeID PK ContactInfoID FK

And I've setup my Entities as ContactInfo, Telephone and Employee. The code i'm trying to use it like:

Dim emp as New EmployeeEntity() emp.ContactInfo.FirstName = "Kas" emp.ContactInfo.LastName = "troNYC" emp.Save(True)

I noticed that the ContactInfo PK is a GUID so I thought maybe i'd try to add

Dim emp as New EmployeeEntity() emp.ContactInfo.ContactInfoID = Guid.NewGuid() emp.ContactInfo.FirstName = "Kas" emp.ContactInfo.LastName = "troNYC" emp.Save(True)

But that didn't work either. Is there some thing that I am missing? Error message looks like:

An exception was caught during the execution of an action query: Cannot insert the value NULL into column 'ContactInformation id', table 'Employee'; column does not allow nulls. INSERT fails. The statement has been terminated.. Check InnerException, QueryExecuted and Parameters of this exception to examine the cause of this exception.

Please help me. I would even be willing to pay someone to speak to me by phone and answer some questions about how to work with this software with regards to my particular project. If any one from staff see's this, question: if I buy the software will you help me out by phone with my current problems? for a fee? Thanks!

Kas

bclubb
User
Posts: 934
Joined: 12-Feb-2004
# Posted on: 04-Feb-2006 03:51:38   

Try this


Dim emp as New EmployeeEntity()
Dim contact as New ContactInfoEntity()
contact.ContactInfoID = Guid.NewGuid()
contact.FirstName = "Kas"
contact.LastName = "troNYC"
emp.ContactInfo = contact
emp.Save(True)

KastroNYC
User
Posts: 96
Joined: 23-Jan-2006
# Posted on: 04-Feb-2006 03:55:14   

I see how that works but it still requires the end programmer of my model to know how the objects are structured together in order to work right? Additionally the end programmer needs to set a key each time they create a new contact info, is there any place in the code I can pre wire this in so that what I was trying to do will work?

emp.ContactInfo.FirstName = "A" emp.ContactInfo.LastName = "B" emp.Save(True)

-Kas

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39930
Joined: 17-Aug-2003
# Posted on: 04-Feb-2006 11:25:24   

You could offer utility methods for that, in your BL tier.

The thing is: you can abstract away some details about your entities, but you always keep other details around, like mandatory fields, or that field is a string field of 50 chars max...

The necessity to set the contactinfo entity is to make the developer realize a new entity is created: contactinfo. It's not part of employee, it's a separate entity. If this would be 'automatic' you run into the risk of having phantom inserts, something which is very hard to debug.

Frans Bouma | Lead developer LLBLGen Pro
KastroNYC
User
Posts: 96
Joined: 23-Jan-2006
# Posted on: 04-Feb-2006 21:03:24   

Thanks for the help Otis! I understand the reasoning behind that and I see how that is the right way to do it. I'm not sure where online but I could of sworn I saw somewhere that when you buy llblgenpro you get a better documentation guide, is that true? I'm having trouble understanding how some things work, where to put my custom code and so forth, i'm using the self-servicing mode and I understand I should put my code in the [EntityName]Entity.vb file however when I tried to default the creation of my guid pk in the New constructor that didn't seem to work, it returned an empty guid even though I entered Guid.NewGuid() in the constructor, where can I find a good basic llblgenpro web project in vb that can show me sample code for doing things like this? Thanks so much for your help!

-Kas

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39930
Joined: 17-Aug-2003
# Posted on: 05-Feb-2006 12:41:55   

KastroNYC wrote:

Thanks for the help Otis! I understand the reasoning behind that and I see how that is the right way to do it. I'm not sure where online but I could of sworn I saw somewhere that when you buy llblgenpro you get a better documentation guide, is that true?

Our manual is 353 printed A4 pages, you want even better documentation? wink . It's not written as a book, so it might be abit dry.

You could have a look at the first free chapters of this book: http://www.lulu.com/content/174470

I'm having trouble understanding how some things work, where to put my custom code and so forth, i'm using the self-servicing mode and I understand I should put my code in the [EntityName]Entity.vb file however when I tried to default the creation of my guid pk in the New constructor that didn't seem to work, it returned an empty guid even though I entered Guid.NewGuid() in the constructor, where can I find a good basic llblgenpro web project in vb that can show me sample code for doing things like this? Thanks so much for your help! -Kas

Please check in the documentation: "Using the generated code -> Selfservicing -> Adding your own code to the generated code "

Frans Bouma | Lead developer LLBLGen Pro