Migration from LLBlgen 4.0 to LLBlgen 5.2

Posts   
1  /  2
 
    
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39616
Joined: 17-Aug-2003
# Posted on: 18-May-2018 10:47:07   

Abhi070290 wrote:

Hi Otis,

I am explaning things from start. I have followed the same procedure suggested by Walaa. I have used LLBLgen files of my Database project and then used these LLBLgen Files in New LLBLGen 5.2 designer to generate the source code in a seperate folder.

I didnt correct any info messages and Warning during the time of code generation.

Then i have changed all the DLL's in my project and used newly created source code.

When i starting building up my code it was throwing error related to this entity [Ordercreatedbyusername]. It was missing in entity files as it was not generated by LLBLgen 5.2 Designer. Therefore i copied everything related to this entity from older code to resolve build errors.

Code is now building up fine but my unit test cases are getting failed throwing this exception:

Result Message: Test method Vestas.NAcelle.VDD.BLL.MSTest.ProcessStepManagerBugTest.SupplierAndItemSearchBug threw exception: SD.LLBLGen.Pro.ORMSupportClasses.ORMValueTypeMismatchException: The value abtya is of type 'System.String' while the field is of type 'System.Nullable`1[System.DateTime]'

What's the exact stack trace of this exception? (Please copy/paste it, no screenshots)

When i started debugging my code, problem was lying in this piece of code:

Public Shared Function GetCreatedByUserName(ByVal vui As String, daa As DataAccessAdapter) As String
    Dim bucket As New RelationPredicateBucket()
    bucket.PredicateExpression.AddWithAnd(VuiFields.Vui = vui)
    bucket.PredicateExpression.AddWithAnd(VuiFields.DeletedTs = DBNull.Value)
    Dim ec As New EntityCollection(Of VuiEntity)
    daa.FetchEntityCollection(ec, bucket, 1)
    If ec.Any() Then
        Return ec(0).CreatedByUserName
    Else
        Return Nothing
    End If
End Function

Public Overridable Property CreatedByUserName As System.String Get Return CType(GetValue(CInt(VuiFieldIndex.CreatedByUserName), True), System.String) End Get Set SetValue(CInt(VuiFieldIndex.CreatedByUserName), value) End Set End Property

Code is not able to set the value of Createdbyusername i.e "abtya".

I think the problem is that there are some files not overwritten by the code generator. The file 'DatabaseGeneric\Helperclasses\FieldInfoProvider.vb' should contain the definition of the fields, please check the InitVuiEntityInfos method, in there the line which defines 'CreatedByUserName' and check whether it indeed defines it as a GetType(String) or something else. If it does define it as a string, please check whether the file is generated by v5.2 or by 4.0. You can check that at the top. Field values are ordered in an array, and it uses the index of the field to obtain the field info. VuiFieldIndex.CreatedByUserName e.g. refers to field index 5, so the fieldinfo at index 5 has to be of that field. It likely is another one, so something's seriously off in your project, which is mainly caused by some files not being overwritten by the code generator.

And yes we RDP to connect to an on premise server. And i have just installed the LLBLgen version from its website itself and then i used its licence file. Same case is there with my colleagues who are using LLBLgen 5.2 version. I hope this time i am able to clarify all your doubts. Please do let me know if you need anything else.

How does this work, you and your collegues all share the same license and designer?

Frans Bouma | Lead developer LLBLGen Pro
Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 18-May-2018 10:53:49   

Also when you say this: (which is the first issue you have encountered. You should investigate why the field has not been generated, as copying the code from the old project to the new one is erroneous. .

When i starting building up my code it was throwing error related to this entity [Ordercreatedbyusername]. It was missing in entity files as it was not generated by LLBLgen 5.2 Designer. Therefore i copied everything related to this entity from older code to resolve build errors.

. So please check the Designer (Edit entity) for that field, whether it's available or not, and what .NET type it has and what is the DB type associated to it.

Abhi070290
User
Posts: 43
Joined: 25-Apr-2018
# Posted on: 21-May-2018 10:14:04   

Hello Otis,

I have checked fieldinfoprovider.vb

Private Sub InitVuiEntityInfos() : Me.AddFieldIndexEnumForElementName(GetType(VuiFieldIndex), "VuiEntity") Me.AddElementFieldInfo("VuiEntity", "CreatedByUserName", GetType(System.String), False, False, False, False, CInt(VuiFieldIndex.CreatedByUserName), 50, 0, 0) : : End Sub

And yes this field has been created by LLBLgen 5.2 designer. And me and my colleagues are using different licenses. We have ordered around 4 licenses for LLBLgen software.

Secondly i want to clarify onething more, 'Createdbyusername' entity is also present in Private Sub InitOrderEntityInfos() Me.AddFieldIndexEnumForElementName(GetType(OrderFieldIndex), "OrderEntity") : Me.AddElementFieldInfo("OrderEntity", "CreatedByUserName", GetType(System.String), False, False, False, True, CInt(OrderFieldIndex.CreatedByUserName), 50, 0, 0) : End Sub

Public Enum OrderFieldIndex [OrderId] [OrderNo] [OuId] [CreatedById] [ChangedById] [CreatedTs] [ChangedTs] [CreatedByStrategicBuyer] [DeletedTs] [Approved] [Completed] [SupplierOrderNo] [VmiOrderId] [MapicsEnvironmentId] [SourceCreatedTs] [CreatedByUserName] [SupplierNumber] AmountOfFields End Enum

Public Enum VuiFieldIndex [Vui] [Requestor] [OrderNumber] [OrderNumberUpdated] [SerialNumber] [SerialNumberUpdated] [SupplierId] [SupplierIdUpdated] [ItemId] [ItemIdUpdated] [CreatedByUserName] [CreatedTs] [DeletedTs] [UpdateLog] [OrderCreatedTs] AmountOfFields End Enum

@ Walaa

You were right 'Ordercreatedbyusername' is not present in LLBLgen Database file. That's why it was not getting generated by LLBLgen 5.2 designer.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39616
Joined: 17-Aug-2003
# Posted on: 21-May-2018 11:50:10   

If the field you're having problems with isn't present in the entity in the designer, then you can't simply 'copy over code', you have to define it in the entity. If there's a field in the table but not in the entity, you can map a field on it, by going to the entity's mapping tab and click the 'reverse engineer unmapped fields' button.

Then when the field is present in the entity, simply generate code and the field should be there. Copying a property over doesn't mean anything, the mapping data etc. doesn't have it and it then causes problems. So the model in the designer should be as it should be with all the fields, then generate code and your tests should work (code should build). If a field is missing in the generated code, then it has to be added to the entity type in the designer, as it can then check mappings etc.

so:

When i starting building up my code it was throwing error related to this entity [Ordercreatedbyusername]. It was missing in entity files as it was not generated by LLBLgen 5.2 Designer. Therefore i copied everything related to this entity from older code to resolve build errors.

is something you shouldn't do.

Frans Bouma | Lead developer LLBLGen Pro
Abhi070290
User
Posts: 43
Joined: 25-Apr-2018
# Posted on: 23-May-2018 09:15:48   

Hi Otis,

Finally i have resolved all the errors in my project otis after making changes in LGP file using 5.2 version LLBLgen designer. This time my each entity matches with the database tables and it resolved all the errors.

Thanks for your help.

Now i need one more help. How can we analyse the performance: -is their any measures to check the performance of code developed by 5.2 designer?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39616
Joined: 17-Aug-2003
# Posted on: 23-May-2018 09:50:55   

A profiler is used to measure performance, so which parts take the most time. You can't measure things otherwise, you need a profiler to do so.

You can use ORM Profiler (https://ormprofiler.com) or use a .net profiler like ants or dottrace.

See also: https://www.llblgen.com/Documentation/5.4/LLBLGen%20Pro%20RTF/Using%20the%20generated%20code/gencode_performancetuning.htm

Frans Bouma | Lead developer LLBLGen Pro
1  /  2