Home
Help
Register
Log in

Search

 
   Active Threads  

You are here: Home > LLBLGen Pro > Bugs & Issues> TypedView Bug
 

Pages: 1
Bugs & Issues
TypedView Bug
Page:1/1 

  Print all messages in this thread  
Poster Message
smcculloch-home
User



Location:

Joined on:
01-Oct-2003 10:25:39
Posted:
15 posts
# Posted on: 02-Oct-2003 17:17:52.  
I think I have found a Typed View Bug.

Steps to reproduce:

Create a View in your database
Create a Typed View in the designer
Generate
Try to query the view applying a Sort Filter, the Order by Clause will be the actual Entity Name rather then the typed view name.

I captured this in the Sql Profiler:-

exec sp_executesql N'SELECT [CategoryView].[CategoryID],[CategoryView].[ForumID],[CategoryView].[CategoryTitle],[CategoryView].[CategoryDescription],[CategoryView].[SortOrder],[CategoryView].[TopicCount],[CategoryView].[PostCount],[CategoryView].[LastPostDate],[CategoryView].[LastPostUserID],[CategoryView].[DateCreated],[CategoryView].[DateLastModified],[CategoryView].[IsCategoryPrivate],[CategoryView].[IsCategoryLocked],[CategoryView].[IsActiveTopic],[CategoryView].[UserName]

FROM [dbo].[CategoryView]

WHERE ( [CategoryView].[ForumID] = @ForumID1)

ORDER BY [ForumCategory].[SortOrder] ASC', N'@ForumID1 int', @ForumID1 = 4


So as you can see the Order By should be [CategoryView].[SortOrder] not [ForumCategory].[SortOrder]

-Scott
  Top
Otis
LLBLGen Pro Team



Location:
The Hague, The Netherlands
Joined on:
17-Aug-2003 18:00:36
Posted:
37696 posts
# Posted on: 02-Oct-2003 17:42:56.  
Can you please paste the code you used to construct the sort clause? I think the sort clause create code isn't correct then

Frans Bouma
LLBLGen Pro / ORM Profiler Lead Developer | Blog | Twitter
 
Top
Otis
LLBLGen Pro Team



Location:
The Hague, The Netherlands
Joined on:
17-Aug-2003 18:00:36
Posted:
37696 posts
# Posted on: 02-Oct-2003 17:47:50.  
This works like a charm:
Code:
InvoicesTypedView invoices = new InvoicesTypedView();
IPredicateExpression invoicesFilter = new PredicateExpression();
FieldCompareValuePredicate filterElement = PredicateFactory.CompareValue(InvoicesFieldIndex.OrderID, ComparisonOperator.GreaterThan, 11000);
invoicesFilter.Add(filterElement);
ISortExpression sorterInvoices = new SortExpression(SortClauseFactory.Create(InvoicesFieldIndex.ExtendedPrice, SortOperator.Descending));
invoices.Fill(0, sorterInvoices, true, invoicesFilter);

Check the line where the sortexpression is constructed. Because the SortClauseFactory contains a lot of overloaded methods which accept different field index types, you can specify for example another field index than the view name to create the sortclause. This then will cause a sortclause that contains a field reference that is not in the view. I think you specified the wrong field index when creating the sortclause Regular Smiley

So if I do:
ISortExpression sorterInvoices = new SortExpression(SortClauseFactory.Create(CustomerFieldIndex.CustomerID, SortOperator.Descending));
in the piece of code above, the code will compile, however the query will contain an order by on Customers.CustomerID, which is not in the view. Regular Smiley
Frans Bouma
LLBLGen Pro / ORM Profiler Lead Developer | Blog | Twitter
 
Top
smcculloch-home
User



Location:

Joined on:
01-Oct-2003 10:25:39
Posted:
15 posts
# Posted on: 03-Oct-2003 00:59:42.  
Otis wrote:
This works like a charm:
Code:
InvoicesTypedView invoices = new InvoicesTypedView();
IPredicateExpression invoicesFilter = new PredicateExpression();
FieldCompareValuePredicate filterElement = PredicateFactory.CompareValue(InvoicesFieldIndex.OrderID, ComparisonOperator.GreaterThan, 11000);
invoicesFilter.Add(filterElement);
ISortExpression sorterInvoices = new SortExpression(SortClauseFactory.Create(InvoicesFieldIndex.ExtendedPrice, SortOperator.Descending));
invoices.Fill(0, sorterInvoices, true, invoicesFilter);

Check the line where the sortexpression is constructed. Because the SortClauseFactory contains a lot of overloaded methods which accept different field index types, you can specify for example another field index than the view name to create the sortclause. This then will cause a sortclause that contains a field reference that is not in the view. I think you specified the wrong field index when creating the sortclause Regular Smiley

So if I do:
ISortExpression sorterInvoices = new SortExpression(SortClauseFactory.Create(CustomerFieldIndex.CustomerID, SortOperator.Descending));
in the piece of code above, the code will compile, however the query will contain an order by on Customers.CustomerID, which is not in the view. Regular Smiley



Hehe, you are exactly right, I am such an idiot! I shouldn't code late at night Embarassed


  Top
Otis
LLBLGen Pro Team



Location:
The Hague, The Netherlands
Joined on:
17-Aug-2003 18:00:36
Posted:
37696 posts
# Posted on: 03-Oct-2003 10:52:06.  
Nah, it's not idiotic, it's a mistake that can happen Regular Smiley I'll close the thread Regular Smiley
Frans Bouma
LLBLGen Pro / ORM Profiler Lead Developer | Blog | Twitter
 
Top
Pages: 1  


Powered by HnD ©2002-2007 Solutions Design
HnD uses LLBLGen Pro

Version: 2.1.12172008 Final.