Change update into insert

Posts   
1  /  2
 
    
JayBee
User
Posts: 275
Joined: 28-Dec-2006
# Posted on: 03-Jan-2008 00:23:13   

I'm using a GridView with an LLBLGenDatasource. Occasionally when a record / entity is updated using the GridView basic controls, I do not want to do an update, but an insert. This to have some kind of log of the old situation.

Is there an easy way to achieve this?

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 03-Jan-2008 04:25:11   

First of all, use yourLLBLGenDataSource.LivePersistence = false and handle the PerformWok event. Then you should to (kind of) clone the entity. Here is a class utility someone created: http://www.llblgen.com/tinyforum/Messages.aspx?ThreadID=7568

Hope helpful.

David Elizondo | LLBLGen Support Team
JayBee
User
Posts: 275
Joined: 28-Dec-2006
# Posted on: 03-Jan-2008 10:49:50   

Thnx,

Found it in the documentation and I think it will wok;-)

JayBee
User
Posts: 275
Joined: 28-Dec-2006
# Posted on: 08-Jan-2008 14:20:19   

Just one other question;

If I set the LivePersistance to false, do I have to handle all the events myself? E.g. will paging work if I do not implement the DbCount event when LivePersistance is set to false?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 08-Jan-2008 17:25:38   

You've to implement the events yourself. Mainly this comes down to a couple of lines per event, you basicly pass on the call to DataAccessAdapter methods with the parameters received in the event args simple_smile

Frans Bouma | Lead developer LLBLGen Pro
JayBee
User
Posts: 275
Joined: 28-Dec-2006
# Posted on: 08-Jan-2008 23:03:16   

I am using SelfServicing and building an ASPNET 2.0 application with SQL Server 2000 as the DBMS.

I tried to add Validator classes via Dependency Injection (web based application using the web-config data as described in the manual) and want to use them for the datasource.

Should I also turn LivePersistance false and handle insert and update events in my program? Or will they also be used in case LivePersistance is true?

When I set LivePersistance to false, I don't see the Validator classes being invoked. Is there a way to debug this?

Also, when I set LivePersistance to false, the gridview does not show the records. I looked at the examples and did not find any databinding actions. What am I overlooking here?

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 09-Jan-2008 10:24:21   

LivePersistence has nothing to do with DI of the Validator class.

When I set LivePersistance to false, I don't see the Validator classes being invoked. Is there a way to debug this? Also, when I set LivePersistance to false, the gridview does not show the records.

Did you handle the various events as shown in the manual?

I looked at the examples and did not find any databinding actions. What am I overlooking here?

Which examples have you looked at?

In the case of fetching, the idea is to fetch the EntityCollection/TypedView...etc of the LLBLGenProDataSource.

JayBee
User
Posts: 275
Joined: 28-Dec-2006
# Posted on: 09-Jan-2008 11:39:26   

To get an idea of how things work I looked at the Example_Validation_11132007 available at the download section. The ASP.NET example is for Adaptor, but regarding the functionality LLBLGenProDataSource I thought there shouldn't be a difference between Adaptor and SelfServicing.

I did not fill in the PerformSelect event. Thanks for the tip; the Gridview data is filled now.

Perhaps the Validator classes are not found; the documentation mentions something about asp.net and naming of the validators. Is it possible to check if the DI has taken place?

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 09-Jan-2008 11:55:39   

You may check the Validator property of an entity, if it's null, then the DI didn't occur.

Have you used the dependencyInjectionInformation section in your web.config file? Please refer to the LLBLGen Pro manual "Using the generated code -> Setting up and using Dependency Injection"

JayBee
User
Posts: 275
Joined: 28-Dec-2006
# Posted on: 09-Jan-2008 12:43:34   

The Validator property is equal to null.

I read that section in the manual and then looked at the adapter example I mentioned. Actually copied the relevant stuff from the example into my own web.config.

In the adapter example the filename is used. In the manual it states that for a web application the fullname should be used. I tried both without result.

I also tried both at the same time with no result.

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 09-Jan-2008 15:44:34   

Are you sure you are specifing the correct path of the Validator assembly with regards to the executable folder?

Please check the following thread for how to use DI settings: http://www.llblgen.com/TinyForum/Messages.aspx?ThreadID=11805

If it doesn't help you out, would you please attach a repro solution?

JayBee
User
Posts: 275
Joined: 28-Dec-2006
# Posted on: 09-Jan-2008 16:24:31   

Hi Walaa,

The thread you are referring to concerns a WinForms app. That differs from a WebForms app. My app is a web application. I am using the full name. According to the documentation and another thread on DI (http://www.llblgen.com/TinyForum/Messages.aspx?ThreadID=11948) one should refer to the fullName and not to the filename.

If you have any ideas. Is it possible to determine that the dependency injection steps itself are executed. I.e. as a result of the content of the web.config?

Jan

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 09-Jan-2008 17:02:51   

I know no other way for testing the DI except checking the property that should have been insjected simple_smile .

Would you please attach a repro solution or at least the config file?

I still believe this could happen because the validator assembly can't be found at runtime, would you please try to copy the validator assembly and paste it inside the bin folder of your web application.

JayBee
User
Posts: 275
Joined: 28-Dec-2006
# Posted on: 09-Jan-2008 19:29:46   

I'll try to build an example using Northwind.

JayBee
User
Posts: 275
Joined: 28-Dec-2006
# Posted on: 10-Jan-2008 01:00:41   

I finished the first attempt. It seems to work.

The website I have problems with runs under IIS, the one I tried to use as a repro not. Could there be a problem in IIS?

I also noticed on the repro that if the validation module can not be located, an error is given. This is not the case in the site that runs under IIS. Strange.

I'll try to bring the repro under IIS and see what happens.

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 10-Jan-2008 09:54:58   

Have you tried to copy the validator assembly in the bin folder of your web application?

JayBee
User
Posts: 275
Joined: 28-Dec-2006
# Posted on: 10-Jan-2008 10:04:37   

With the Validator assembly you mean the compiled validator project I wrote that does the validation? It is in the bin (made a reference in the website so it gets copied to the debug and release bin by VS2005).

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 10-Jan-2008 10:44:17   

With the Validator assembly you mean the compiled validator project I wrote that does the validation?

Yes I ment that.

Waiting for your repro.

JayBee
User
Posts: 275
Joined: 28-Dec-2006
# Posted on: 10-Jan-2008 11:08:53   

Hi Walaa,

As mentioned the repro works fine under the webserver of VS2005. So there is no need to send that one in. I'm trying to get it to run under IIS and find out if that could cause the problem.

Regarding the DI part in the config file there is no difference between the repro version and the real version. In the real version I also have the sqlServerCatalogNameOverwrites. Could that give problems?

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 10-Jan-2008 11:40:27   

Regarding the DI part in the config file there is no difference between the repro version and the real version. In the real version I also have the sqlServerCatalogNameOverwrites. Could that give problems?

I don't think so.

Just send the not-working IIS repro and we can check it under IIS too.

JayBee
User
Posts: 275
Joined: 28-Dec-2006
# Posted on: 10-Jan-2008 12:15:48   

Just send the not-working IIS repro and we can check it under IIS too.

The repro also runs under IIS without a problem. I noticed a difference between the repro and the original:

The Website in the repro is concerned a website by VS2005. The Website in the original is a project with website properties. I'll try to convert the repro website to a Web Application and see what happens.

JayBee
User
Posts: 275
Joined: 28-Dec-2006
# Posted on: 10-Jan-2008 21:19:06   

Al seems to keep on working, also for the Web Application template. Something else must be causing it. I'll rebuild the site that is giving the problems and perhaps that will solve it.

In the repro application I have encountered another problem. Field value checking does not work out of the box. This has been discussed in http://www.llblgen.com/TinyForum/Messages.aspx?ThreadID=9206&HighLight=1

I'll try their suggestion.

I have to agree with Frans that a lot of errors raised in the forums find their origin in the limitations common MS facilities. It would be nice however to have a lot of examples illustrating the way applications can work properly with LLBLGen.

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 11-Jan-2008 10:15:32   

It would be nice however to have a lot of examples illustrating the way applications can work properly with LLBLGen.

We have many examples in the download section of our website. PLus the 400+ pages of docs simple_smile

JayBee
User
Posts: 275
Joined: 28-Dec-2006
# Posted on: 11-Jan-2008 20:15:50   

Walaa wrote:

We have many examples in the download section of our website. PLus the 400+ pages of docs simple_smile

The example of DI and Validators is the only example of this technology for a web-based application. It has field-value validation, but when field-validation results in an error, this error is not shown on the web-page. The field itself however is not changed in the faulty value, but instead it is reset to an empty value. It does support entity validation by the use of ORM exeptions.

There is no proper working example for ASP.NETcry But this is a consequence of the functional limitations of dotnet.

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 12-Jan-2008 04:56:50   

When a field value didn't pass the entity field validation rules, the field value change is rejected so the value remains as the original. If the original is null, the value remains null. The web validation example contains four scenarios. So, inspect them and let us know if you have questions wink

David Elizondo | LLBLGen Support Team
1  /  2