Wrox Programmer Forums
|
BOOK: ASP.NET 3.5 Enterprise Application Development with Visual Studio 2008: Problem Design Solutio
This is the forum to discuss the Wrox book ASP.NET 3.5 Enterprise Application Development with Visual Studio 2008: Problem Design Solution by Vincent Varallo; ISBN: 9780470396865
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: ASP.NET 3.5 Enterprise Application Development with Visual Studio 2008: Problem Design Solutio section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 26th, 2009, 07:32 PM
Authorized User
 
Join Date: Mar 2008
Posts: 62
Thanks: 1
Thanked 3 Times in 3 Posts
Send a message via Yahoo to kalel_4444
Default QueryBuilder: Sort the QueryField Attribuites ??

Hello,

Anyone have a take on sorting / OrderBy the QueryFieldAttributes that are created in the DAL/...DataQuery.cs files ?

The QueryBuilder that was created with this book gives great flexibility. Vince, definitely thank you for this one.

I tried enumerating through the QueryFields in the Builder right after calling the GetCustomAttributes method. But I failed because it's of type object[] and I tried doing something like:
IEnumerable<QueryFieldAttribute> qfa = QueryFields.OrderBy(q => q.FriendlyFieldName);

I'm completely shooting in the dark on this since I never worked with QueryFieldAttributes till now. Is there a simple way of doing this and I'm just completely looking at this wrong..?

As always, any assistance is appreciated.
Ronnie
 
Old October 27th, 2009, 01:24 AM
Authorized User
 
Join Date: Mar 2008
Posts: 62
Thanks: 1
Thanked 3 Times in 3 Posts
Send a message via Yahoo to kalel_4444
Default

Sorry, I guess I wasn't clear. I meant the actual Query Field Attribute List that is declared in the QueryData class and populates ddlFields in the QueryBuilder, not the results that populate ddlValues.

For example:
  • Day Type [0]
  • Current Owner [1]
  • Request Type [2]
  • Current State [3]
Thanks,
Ronnie
 
Old October 27th, 2009, 08:46 AM
Wrox Author
 
Join Date: Jan 2009
Posts: 73
Thanks: 0
Thanked 7 Times in 7 Posts
Default

try this

var
sortedQueryFields = from q in QueryFields
where q isQueryFieldAttribute && !(q isRequiredQueryFieldAttribute)
orderby ((QueryFieldAttribute)q).FriendlyFieldName
select q;
foreach (object attribute in sortedQueryFields)
{
QueryFieldAttribute qfa = (QueryFieldAttribute)attribute;

_ddlFields.Items.Add(
newListItem(qfa.FriendlyFieldName, qfa.FieldName));
}
_ddlFields.Items.Insert(0,
"");
The Following User Says Thank You to varallov For This Useful Post:
kalel_4444 (October 27th, 2009)
 
Old October 27th, 2009, 09:46 AM
Authorized User
 
Join Date: Mar 2008
Posts: 62
Thanks: 1
Thanked 3 Times in 3 Posts
Send a message via Yahoo to kalel_4444
Default

Exellent, works great..!!!

Thank you
 
Old November 9th, 2009, 05:59 PM
Authorized User
 
Join Date: Mar 2009
Posts: 79
Thanks: 4
Thanked 4 Times in 4 Posts
Default

kalel,

thought I would post in this thread since you are familular with this portion.

Having a problem with the Query Builder. I can get all the way to the ReportQuery.aspx but when i click the Preview button I get the following.

Code:

if (QueryBuilder1.GetWhereClause(ref whereClause, ref validationErrors))
{
ENTReportBO currentReport = CurrentReport;
ReportDocument report = newReportDocument();
report.Load(Server.MapPath(currentReport.FileName));
Type objectType = Type.GetType(currentReport.ObjectName);
object listObject = Activator.CreateInstance(objectType);
 
//This is where it fails
object[] data = (object[])objectType.InvokeMember("Select", BindingFlags.InvokeMethod, null, listObject, newobject[] { whereClause });
I get the following error:
"Exception has been thrown by the target of an invocation."

The debugger shows that the data object is null. The SQL that I used in the DAL QueryData file uses a good amount of aggregate functions. Do you think this is the cause. I have looked and doubled check all that I can think of. Also, I added a query filed that is not pulled by the selet statement, but I cant include that field in the Select statement because it has to be apart of an aggregate function which isnt possible (datetime). Any help is appreciated.

Thanks
 
Old November 9th, 2009, 09:02 PM
Wrox Author
 
Join Date: Jan 2009
Posts: 73
Thanks: 0
Thanked 7 Times in 7 Posts
Default

Try putting a breakpoint in your Select method and a try/catch block to trap the exception. You'll be able to get a better idea of what is doing on if you get the real error message. It could be as simple as an SQL typo.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Dynamic sort order or sort datatype kapy_kal XSLT 2 September 18th, 2007 02:10 PM
how to sort cross tab.sort based on row total joxa83 Crystal Reports 7 March 2nd, 2006 09:12 AM
Sort @* sheila XSLT 2 July 17th, 2005 04:01 PM
Unable to sort using xsl sort command sly_jimmy_boy XSLT 3 June 17th, 2005 05:15 AM
SORT pallone XSLT 13 February 25th, 2005 11:54 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.