Filter Predicate expression for SQL Views

Posts   
 
    
Posts: 2
Joined: 03-Feb-2014
# Posted on: 03-Feb-2014 06:50:25   

Hi,

I am currently converting my project from LLBLGEN 1.1 to LLBLGEN 4.1 I am having problems with the filtering expression since PredicateFactory is no longer exist in 4.1

I would like to create a filter in one of the column from a view: Dim udtSelectFilter As New PredicateExpression in 1.1: udtSelectFilter.Add (FactoryClasses.PredicateFactory.CompareValue(JobFieldIndex.Intranet, ComparisonOperator.Equal, True)

Public Enum JobFieldIndex [CreatedDate] [CreatorEmployeeId] [Internet] [Intranet] [JobCompleted] [JobName] End Enum

in 4.1 we replaced the filter statement with: udtSelectFilter.Add(JobFields.Intranet = True) But this causes an error [Document Management].[dbo].[tblJobs].Intranet do not exist

Public Class JobFields ''' <summary>Creates a new Job1TypedView.Intranet field instance</summary> Public Shared ReadOnly Property [Intranet] As EntityField Get Return CType(EntityFieldFactory.Create(Job1FieldIndex.Intranet), EntityField) End Get End Property

''' <summary>Creates a new Job1TypedView.Internet field instance</summary> Public Shared ReadOnly Property [Internet] As EntityField Get Return CType(EntityFieldFactory.Create(Job1FieldIndex.Internet), EntityField) End Get End Property End Class

After running the SQL profiler to see what SQL LLBLGEN has created, we realised that the where clause of the SQL statement is incorrect in that the column name is fully qualified with the database name, table name and column name instead of just the column name SELECT [DocumentManagement].[dbo].[vwJobs].[ID] AS [Id], [DocumentManagement].[dbo].[vwJobs].[JobName], [DocumentManagement].[dbo].[vwJobs].[Intranet], [DocumentManagement].[dbo].[vwJobs].[Internet], FROM [DocumentManagement].[dbo].[vwJobs]
WHERE ([DocumentManagement].[dbo].[tblJobs].[Intranet] =1)

instead of the correct where SELECT [DocumentManagement].[dbo].[vwJobs].[ID] AS [Id], [DocumentManagement].[dbo].[vwJobs].[JobName], [DocumentManagement].[dbo].[vwJobs].[Intranet], [DocumentManagement].[dbo].[vwJobs].[Internet], FROM [DocumentManagement].[dbo].[vwJobs]
WHERE (Intranet =1)

Can you please help with the correct filter predicate statement to give us the right SQL to do the column search in the SQL view?

Thanks and Regards, Kristina

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39833
Joined: 17-Aug-2003
# Posted on: 03-Feb-2014 10:20:00   

You should use the fields object of the typed view in your predicate. So your predicate should be:

udtSelectFilter.Add(Job1Fields.Intranet = True)

(so Job1, not Job. Job1 seems to be your typedview mapped onto the same view as the entity Job, correct?)

Frans Bouma | Lead developer LLBLGen Pro
Posts: 2
Joined: 03-Feb-2014
# Posted on: 04-Feb-2014 03:14:52   

Thanks Frans. I got it sorted. You are right, the table "Job" and the view "Job1" are being confused. Job1 should be used when referring to the view but in this case Job is used intsead.

Regards, Kristina