Adding Own SQL Statement to generated code

Posts   
 
    
yj
User
Posts: 39
Joined: 07-Aug-2007
# Posted on: 21-Aug-2007 14:03:20   

LLBLGen Pro 2.0 ASP.NET C# 2.0 SelfServicing Oracle

Hi guys, I would like to ask about the possiblity of adding our own SQL statement into the generated code? This is required as we urgently need to develop a program before we can actually fully understand the functionality in LLBL Gen Pro, hence we need a workaround to achieve some of the functions. One example is that we need to get the Max(ID) from a table with attrib (ID, Description). Thank you.

goose avatar
goose
User
Posts: 392
Joined: 06-Aug-2007
# Posted on: 21-Aug-2007 18:45:44   

You have 2 options: 1) using stored procedures 2) using DBFunctionCall

yj
User
Posts: 39
Joined: 07-Aug-2007
# Posted on: 22-Aug-2007 06:28:57   

Hi goose, thanks for the suggestion However, i m looking for a way to actually without regenerating the code, i can insert my own SQL queries.

One major problem i m facing now is this: suppose i have 2 tables: Customer, and Country Customer table has an foreign key accessing to Country table.

Now that i want to display a gridview in ASP.NET (C#) such us: Cust Name , Country (Name instead of ID stored in Customer table)

Then i would like to utilize the auto handling of edit and delete of GridView. I had tried using Typedlist, but it seems cumbersome, and most importantly it does not support GridView auto handling if i m to bind it at run time, e.g.:

CustomerListTypedList custList = new CustomerListTypedList(); GridView.Datasource = custList;

Can anyone point me to the direction for this? Thanks

goose avatar
goose
User
Posts: 392
Joined: 06-Aug-2007
# Posted on: 22-Aug-2007 06:55:00   

Hi yj, you don't have to regenerate the whole code in order to use DBFunctionCall you could create a partial class or use the LLBL's user code regions.

Check this thread to obtain 2waybinding with LLBL's framework almost out of the box:

http://www.llblgen.com/TinyForum/Messages.aspx?ThreadID=10802

good luck,simple_smile

yj
User
Posts: 39
Joined: 07-Aug-2007
# Posted on: 22-Aug-2007 08:35:09   

hi goose, thank you very much for the guidance. since we had talked about this, may i further enquire about playing around with Collection classes? Currently i m using LLBLDataSource to bind the data in my Oracle tables to be shown in a gridview in my asp.net page. Now that I intend to add a new row when the datasource is empty, the solution i found online is to add an empty row into the datasource, and then showing it in the GridView. However, I have tried the following code to insert a new row, but to no avail, any comments on this?

if (dsMyDatasource.EntityCollection.Count == 0) { MyEntity objEmptyRow = new MyEntity (); dsMyDatasource.EntityCollection.Add(objEmptyRow); dsMyDatasource.Refetch = true; }

grvMyGridView.Datasource = dsMyDataSource grvMyGridView.Databind();

//the dsMyDataSource is the ID for LLBLGenProDataSource object

Thanks

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 22-Aug-2007 16:32:32   

Now that I intend to add a new row when the datasource is empty, the solution i found online is to add an empty row into the datasource, and then showing it in the GridView. However, I have tried the following code to insert a new row, but to no avail, any comments on this?

if (dsMyDatasource.EntityCollection.Count == 0) { MyEntity objEmptyRow = new MyEntity (); dsMyDatasource.EntityCollection.Add(objEmptyRow); dsMyDatasource.Refetch = true; }

grvMyGridView.Datasource = dsMyDataSource grvMyGridView.Databind();

That's not the approach I'd recommend. Use the EmptyTemplate of the GridView to insert the first row in an empty Grid. Then you might use the Footer of the GridView to add subsequent records. Check the following post: http://walaapoints.blogspot.com/2007/05/inserting-from-aspnet-gridview.html