﻿<?xml version="1.0" encoding="utf-8"?><rss version="2.0"><channel><title>Akal Tech RSS Feed</title><link>http://akaltech.com/Views/Forum/Default.aspx</link><description>Akal Tech Forum Topics</description><copyright>Akal Tech (c) 2010. All rights reserved.</copyright><language>en-us</language><lastBuildDate>9/10/2010 12:30:28 PM GMT</lastBuildDate><item><title>Topic: How do I add columns dynamically?</title><description>&lt;br&gt;Topic Description: Your product looks really good but I have a scenario that I am not sure if it can handle or not.&amp;nbsp; I have a few tables that the "end user" can customize by adding custom columns. We are able to execute alter statements without any problem, and have the meta data for custom columns in xml files. What I would like to do is somehow tell the Quick Objects to include the custom columns in the Find methods so I could get a dataset with the custom columns included. This needs to happen at runtime and it is not possible to regen the code.&lt;br&gt;&lt;br&gt;I have looked high and low for this type of functionality but no product so far can handle this.&amp;nbsp; So can you do this?&lt;br&gt;&lt;br&gt;Cheers!&lt;br&gt;Ryan&lt;br&gt;&lt;hr style="height:1px;"&gt;Replies: 4&lt;br&gt;Last Reply: Thu, 04 Sep 2008 15:44:40 GMT&lt;br&gt;Reply By: Ryan Aljets&lt;hr style="height:1px;"&gt;</description><link>http://akaltech.com/Views/Forum/Topic.aspx?BPT=5&amp;PT=7&amp;APT=43</link><pubDate>Thu, 04 Sep 2008 15:44:40 GMT</pubDate></item><item><title>Reply: Re: How do I add columns dynamically?</title><description>Thanks for the fast reply and sample code! Works great and it is easy!&lt;br&gt;&lt;br&gt;Cheers :)&lt;br&gt;Ryan&lt;br&gt;</description><link>http://akaltech.com/Views/Forum/Topic.aspx?BPT=5&amp;PT=7&amp;APT=43</link><pubDate>Thu, 04 Sep 2008 15:44:40 GMT</pubDate></item><item><title>Reply: Re: How do I add columns dynamically?</title><description>Here is the code that shows how to add validation to a field:&lt;br&gt;&lt;br&gt;&lt;div style="border: 1px solid rgb(127, 157, 185); overflow: auto; background-color: white; width: 100%; line-height: 100% ! important; font-family: Courier New; font-size: 11px;"&gt;&lt;table style="border-width: 0px; border-bottom: 0px solid rgb(238, 238, 238); margin: 2px 0px; width: 99%; border-collapse: collapse; background-color: rgb(255, 255, 255);" cellpadding="0" cellspacing="0"&gt;&lt;col style="border-bottom: 1px solid rgb(247, 247, 247); font-family: Courier New; font-size: 11px; padding-left: 10px; white-space: nowrap;"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;&lt;font style="font-size: 11px;"&gt;StringField&amp;nbsp;sf&amp;nbsp;=&amp;nbsp;&lt;/font&gt;&lt;font style="color: blue;"&gt;new&lt;/font&gt;&lt;font style="font-size: 11px;"&gt;&amp;nbsp;StringField(&lt;/font&gt;&lt;font style="color: blue;"&gt;this&lt;/font&gt;&lt;font style="font-size: 11px;"&gt;,&amp;nbsp;xn.Attributes[&lt;/font&gt;&lt;font style="color: blue;"&gt;"Name"&lt;/font&gt;&lt;font style="font-size: 11px;"&gt;].Value);&amp;nbsp;&lt;/font&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style="background-color: rgb(247, 247, 247);"&gt;&lt;font style="color: blue;"&gt;if&lt;/font&gt;&lt;font style="font-size: 11px;"&gt;&amp;nbsp;(xn.Attributes[&lt;/font&gt;&lt;font style="color: blue;"&gt;"Required"&lt;/font&gt;&lt;font style="font-size: 11px;"&gt;].Value&amp;nbsp;==&amp;nbsp;&lt;/font&gt;&lt;font style="color: blue;"&gt;"True"&lt;/font&gt;&lt;font style="font-size: 11px;"&gt;)&amp;nbsp;&lt;/font&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;{&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style="background-color: rgb(247, 247, 247);"&gt;&amp;nbsp;&amp;nbsp;&lt;font style="color: blue;"&gt;new&lt;/font&gt;&lt;font style="font-size: 11px;"&gt;&amp;nbsp;RequiredFieldValidator(sf,&amp;nbsp;&lt;/font&gt;&lt;font style="color: blue;"&gt;true&lt;/font&gt;&lt;font style="font-size: 11px;"&gt;);&amp;nbsp;&lt;/font&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;}&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style="background-color: rgb(247, 247, 247);"&gt;&lt;font style="color: blue;"&gt;if&lt;/font&gt;&lt;font style="font-size: 11px;"&gt;&amp;nbsp;(xn.Attributes[&lt;/font&gt;&lt;font style="color: blue;"&gt;"RegularExpression"&lt;/font&gt;&lt;font style="font-size: 11px;"&gt;]&amp;nbsp;!=&amp;nbsp;&lt;/font&gt;&lt;font style="color: blue;"&gt;null&lt;/font&gt;&lt;font style="font-size: 11px;"&gt;)&amp;nbsp;&lt;/font&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;{&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style="background-color: rgb(247, 247, 247);"&gt;&amp;nbsp;&amp;nbsp;RegularExpressionFieldValidator&amp;nbsp;emValidator&amp;nbsp;=&amp;nbsp;&lt;font style="color: blue;"&gt;new&lt;/font&gt;&lt;font style="font-size: 11px;"&gt;&amp;nbsp;RegularExpressionFieldValidator(sf,&amp;nbsp;&lt;/font&gt;&lt;font style="color: blue;"&gt;true&lt;/font&gt;&lt;font style="font-size: 11px;"&gt;);&amp;nbsp;&lt;/font&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&amp;nbsp;&amp;nbsp;emValidator.Expression&amp;nbsp;=&amp;nbsp;xn.Attributes[&lt;font style="color: blue;"&gt;"RegularExpression"&lt;/font&gt;&lt;font style="font-size: 11px;"&gt;].Value;&amp;nbsp;&lt;/font&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style="background-color: rgb(247, 247, 247);"&gt;}&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;br&gt;&lt;br&gt;If you need to access the validators at a later stage you can simply use the Validators collection on an instance of a field.&lt;br&gt;&lt;br&gt;&lt;span style="color: rgb(255, 165, 0); font-weight: bold;"&gt;Thanks,&lt;/span&gt;&lt;br style="color: rgb(255, 165, 0); font-weight: bold;"&gt;&lt;span style="color: rgb(255, 165, 0); font-weight: bold;"&gt;Ish&lt;/span&gt;&lt;br style="color: rgb(255, 165, 0); font-weight: bold;"&gt;&lt;br style="color: rgb(255, 165, 0); font-weight: bold;"&gt;&lt;span style="color: rgb(255, 165, 0); font-weight: bold;"&gt;Quick Objects Support&lt;/span&gt;&lt;br&gt;&lt;br&gt;</description><link>http://akaltech.com/Views/Forum/Topic.aspx?BPT=5&amp;PT=7&amp;APT=43</link><pubDate>Tue, 02 Sep 2008 18:29:56 GMT</pubDate></item><item><title>Reply: Re: How do I add columns dynamically?</title><description>WOW! This looks like exactly what we need!!&lt;br&gt;&lt;br&gt;I will give it a try but have one more question.&amp;nbsp; We've got close to 50 tables that we are allowing the end user to add custom fields. If I understand correctly I would need to write this code for each of the tables or is there an easier way?&amp;nbsp; Its no big deal as being able to do this is a big deal for our project.&lt;br&gt;&lt;br&gt;Since you mentioned it can you also show how I can add validation to these dynamic fields?&lt;br&gt;Cheers!&lt;br&gt;Ryan&lt;br&gt;</description><link>http://akaltech.com/Views/Forum/Topic.aspx?BPT=5&amp;PT=7&amp;APT=43</link><pubDate>Tue, 02 Sep 2008 05:33:38 GMT</pubDate></item><item><title>Reply: Re: How do I add columns dynamically?</title><description>The scenario you have mentioned can be easily handled. See the following link for information on how you can dynamically specify schema:&lt;br&gt;&lt;br&gt;&lt;a href="http://www.akaltech.com/Views/Forum/T/Dynamically_specify_object_schema/BPT/5/PT/5/APT/20/1/Topic.aspx"&gt;http://www.akaltech.com/Views/Forum/T/Dynamically_specify_object_schema/BPT/5/PT/5/APT/20/1/Topic.aspx&lt;/a&gt;&lt;br&gt;&lt;br&gt;The above approach can also be mixed with a class that is generated.&amp;nbsp; In your scenario if you have a Customers table that is customized by your end user you can capture the Customers object initialized event or override the method and loop through your xml nodes that contain field definition and add fields dynamically to the Customers object.&amp;nbsp; The dynamically added fields are not only available in Find calls but are available to all methods and these fields can be included in Insert, Update methods etc.&lt;br&gt;&lt;br&gt;&lt;div style="border: 1px solid rgb(127, 157, 185); overflow: auto; background-color: white; width: 100%; line-height: 100% ! important; font-family: Courier New; font-size: 11px;"&gt;&lt;table style="border-width: 0px; border-bottom: 0px solid rgb(238, 238, 238); margin: 2px 0px; width: 99%; border-collapse: collapse; background-color: rgb(255, 255, 255);" cellpadding="0" cellspacing="0"&gt;&lt;col style="border-bottom: 1px solid rgb(247, 247, 247); font-family: Courier New; font-size: 11px; padding-left: 10px; white-space: nowrap;"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;&lt;font style="font-size: 11px;"&gt;&lt;/font&gt;&lt;font style="color: blue;"&gt;foreach&lt;/font&gt;&lt;font style="font-size: 11px;"&gt;(XmlNode&amp;nbsp;xn&amp;nbsp;&lt;/font&gt;&lt;font style="color: blue;"&gt;in&lt;/font&gt;&lt;font style="font-size: 11px;"&gt;&amp;nbsp;MyFields.Nodes)&amp;nbsp;&lt;/font&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style="background-color: rgb(247, 247, 247);"&gt;{&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;font style="color: blue;"&gt;if&lt;/font&gt;&lt;font style="font-size: 11px;"&gt;&amp;nbsp;(xn.Attributes[&lt;/font&gt;&lt;font style="color: blue;"&gt;"Type"&lt;/font&gt;&lt;font style="font-size: 11px;"&gt;].Value&amp;nbsp;==&amp;nbsp;&lt;/font&gt;&lt;font style="color: blue;"&gt;"String"&lt;/font&gt;&lt;font style="font-size: 11px;"&gt;)&amp;nbsp;&lt;/font&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style="background-color: rgb(247, 247, 247);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;font style="color: blue;"&gt;new&lt;/font&gt;&lt;font style="font-size: 11px;"&gt;&amp;nbsp;StringField(&lt;/font&gt;&lt;font style="color: blue;"&gt;this&lt;/font&gt;&lt;font style="font-size: 11px;"&gt;,&amp;nbsp;xn.Attributes[&lt;/font&gt;&lt;font style="color: blue;"&gt;"Name"&lt;/font&gt;&lt;font style="font-size: 11px;"&gt;].Value); &lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Each field constructor has multiple overloads allow you to pass the instance of the business object and the name of the field.&lt;br&gt;&lt;/font&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style="background-color: rgb(247, 247, 247);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;font style="color: blue;"&gt;else&lt;/font&gt;&lt;font style="font-size: 11px;"&gt;&amp;nbsp;(xn.Attributes[&lt;/font&gt;&lt;font style="color: blue;"&gt;"Type"&lt;/font&gt;&lt;font style="font-size: 11px;"&gt;].Value&amp;nbsp;=&amp;nbsp;&lt;/font&gt;&lt;font style="color: blue;"&gt;"Integer"&lt;/font&gt;&lt;font style="font-size: 11px;"&gt;);&lt;br&gt;&lt;/font&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style="background-color: rgb(247, 247, 247);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;font style="color: blue;"&gt;new&lt;/font&gt;&lt;font style="font-size: 11px;"&gt;&amp;nbsp;Int32Field(&lt;/font&gt;&lt;font style="color: blue;"&gt;this&lt;/font&gt;&lt;font style="font-size: 11px;"&gt;,&amp;nbsp;xn.Attributes[&lt;/font&gt;&lt;font style="color: blue;"&gt;"Name"&lt;/font&gt;&lt;font style="font-size: 11px;"&gt;].Value);&amp;nbsp;&lt;/font&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style="background-color: rgb(247, 247, 247);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;}&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style="background-color: rgb(247, 247, 247);"&gt;&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;br&gt;The above can be done at any stage as per your requirement. Once you have added the fields you can access them like this:&lt;br&gt;&lt;br&gt;&lt;div style="border: 1px solid rgb(127, 157, 185); overflow: auto; background-color: white; width: 100%; line-height: 100% ! important; font-family: Courier New; font-size: 11px;"&gt;&lt;table style="border-width: 0px; border-bottom: 0px solid rgb(238, 238, 238); margin: 2px 0px; width: 99%; border-collapse: collapse; background-color: rgb(255, 255, 255);" cellpadding="0" cellspacing="0"&gt;&lt;col style="border-bottom: 1px solid rgb(247, 247, 247); font-family: Courier New; font-size: 11px; padding-left: 10px; white-space: nowrap;"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;&lt;font style="font-size: 11px;"&gt;&lt;/font&gt;&lt;font style="color: blue;"&gt;using&lt;/font&gt;&lt;font style="font-size: 11px;"&gt;&amp;nbsp;(Customers&amp;nbsp;c&amp;nbsp;=&amp;nbsp;&lt;/font&gt;&lt;font style="color: blue;"&gt;new&lt;/font&gt;&lt;font style="font-size: 11px;"&gt;&amp;nbsp;Customers())&amp;nbsp;&lt;/font&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style="background-color: rgb(247, 247, 247);"&gt;{&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;c.ObjectMode&amp;nbsp;=&amp;nbsp;ObjectModes.Save;&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style="background-color: rgb(247, 247, 247);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;c.CustomerID.Value&amp;nbsp;=&amp;nbsp;1;&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;c.FirstName.Value&amp;nbsp;=&amp;nbsp;TextBox_FirstName.Text;&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style="background-color: rgb(247, 247, 247);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;font style="color: green;"&gt;//&amp;nbsp;Now&amp;nbsp;if&amp;nbsp;you&amp;nbsp;want&amp;nbsp;to&amp;nbsp;access&amp;nbsp;a&amp;nbsp;dynamically&amp;nbsp;created&amp;nbsp;field&amp;nbsp;you&amp;nbsp;need&amp;nbsp;to&amp;nbsp;know&amp;nbsp;the&amp;nbsp;name&lt;/font&gt;&lt;font style="font-size: 11px;"&gt;&amp;nbsp;&lt;/font&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;font style="color: green;"&gt;//&amp;nbsp;and&amp;nbsp;the&amp;nbsp;code&amp;nbsp;you&amp;nbsp;will&amp;nbsp;write:&lt;/font&gt;&lt;font style="font-size: 11px;"&gt;&amp;nbsp;&lt;/font&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style="background-color: rgb(247, 247, 247);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;c.Fields[myCustomFieldName1].Value&amp;nbsp;=&amp;nbsp;TextBox_Custom1.Text;&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;c.Fields[myCustomFieldName2].Value&amp;nbsp;=&amp;nbsp;TextBox_Custom2.Text;&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style="background-color: rgb(247, 247, 247);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;font style="color: blue;"&gt;if&lt;/font&gt;&lt;font style="font-size: 11px;"&gt;&amp;nbsp;(c.Update())&amp;nbsp;&lt;/font&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style="background-color: rgb(247, 247, 247);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;font style="color: green;"&gt;//&amp;nbsp;tell&amp;nbsp;user&amp;nbsp;that&amp;nbsp;changes&amp;nbsp;saved&lt;/font&gt;&lt;font style="font-size: 11px;"&gt;&amp;nbsp;&lt;/font&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style="background-color: rgb(247, 247, 247);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;}&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;br&gt;You can even include such a custom field in search criteria, sort or group by clause.&amp;nbsp; Even field validators can be added to the dynamically created fields :)&lt;br&gt;&lt;br&gt;Hope this is helpful, if you need any further help please don't hesitate to contact us.&lt;br&gt;&lt;br&gt;&lt;span style="color: rgb(255, 165, 0); font-weight: bold;"&gt;Thanks,&lt;/span&gt;&lt;br style="color: rgb(255, 165, 0); font-weight: bold;"&gt;&lt;span style="color: rgb(255, 165, 0); font-weight: bold;"&gt;Ish&lt;/span&gt;&lt;br style="color: rgb(255, 165, 0); font-weight: bold;"&gt;&lt;br style="color: rgb(255, 165, 0); font-weight: bold;"&gt;&lt;span style="color: rgb(255, 165, 0); font-weight: bold;"&gt;Quick Objects Support&lt;/span&gt;&lt;br style="color: rgb(75, 0, 130);"&gt;&lt;br&gt;</description><link>http://akaltech.com/Views/Forum/Topic.aspx?BPT=5&amp;PT=7&amp;APT=43</link><pubDate>Mon, 01 Sep 2008 23:04:40 GMT</pubDate></item></channel></rss>