Hi, Thank you for your posting. This is essentially what I am doing with my DAL however am using reflection to make the DAL more generic across objects. As such, the column names in the returned data set must match the property names on the object. Additionally, my DAL is able to perform an eager-loading of sub-structures. It is for this eager loading that I need to have the table name returned as part of the column name e.g. Address -- ID -- Line1 -- Line2 -- Country -- -- ID -- -- Name -- Postcode By performing a join between the Address table and Country table, I can eagerly load the country information as a structure into the Address object. I just need to be able to identify the ID and Name fields as belonging the Country structure by prepending 'Country.' to the names. In the above example, it's fine to explicity alias the field names however I would like a solution which could perform something like... SELECT Address.ID AS ID, Address.Line1 AS Line1, Address.Line2 AS Line2, Country.*, Address.Postcode AS Postcode FROM Address LEFT JOIN Country etc... and which would rename the fields in Country to Country.ID and Country.Name. Obviously I could use a view for this however there may be times when I need the ID and Name property without the 'Country.' prefix. In such instances, it would be nice to reuse the same view instead of having a view that prepends the prefix and a view which does not.
techieboi
Posts
-
Table name as part of column name -
Table name as part of column nameThat is correct. In some instances I will be selecting fields from a view and would like to simply have SELECT * FROM vAddress AS Address which would output Address.ID, Address.Line1, Address.Line2 Thank you for your help. Looks like I'm gonna have to explicitly state the aliases in my procs. Cheers
-
Table name as part of column nameI'm attempting to build a DAL that will automatically create and populate objects from the results of a database call. As such, I need the data to be returned in column names that represent the object they are populating such as object.property e.g. Address.ID, Address.Line1 Sometimes I need just the property names e.g. ID, Line1, Line2 and other times I need Address.ID, Address.Line1, Address.Line2. It would be nice to have a view that I can call which returns the relevent fields and then I can simply prepend the object name to each of the fields when required.
-
Table name as part of column nameHi! Thank you for your reply. Unfortunately explicitly naming the columns is the only way I've found to do this so far. I would however like to be able to do something like SELECT * FROM Address and retrieve the columns as [Address].[name]. Do you know of a way of doing this without explicitly aliasing the column names please?
-
Table name as part of column nameHi guys, Is there any way to have SQL Server return the table name as part of the column please? In my example, I would like to do something akin to... SELECT * FROM [Address] and have SQL Server return a result set containing columns with "Address." prepended to the column name. Address.ID, Address.Line1, Address.Line2 Many Thanks for any help you can provide!
-
Programmer's definition of oxymoron!"Jeeze, that's some good VB code" ;-) Made me laugh anyways, maybe I should be getting out a bit more!
-
anonymous delegates with dynamic codeAlthough as a programmer this approach appears to make sense to you (you are loading source code into a dynamic method), to the computer the approach does not make sense as the source code you are loading is not compiled. In order to achieve this, you would have to load the source code then compile it at run-time and then execute it most likely using reflection ;->
-
how can do mathmetical calculation in aspNot really sure if this answers your question... income = 100000 taxRate = 0.22 '22% ' Calculate the amount of tax payable taxPayable = income * taxRate; %>]]>
Your Income Is:
]]>
Your Tax Is:
]]>
Your Take Home Salary Is:
]]>
-
Rotate ProblemHi, Regarding your problem, the best way to flip text (of which I know) is to convert the text to an image. Once it's an image, you can do all sorts of kewl stuff to it. Depending on whether you're working in a web or windows environment, once you have flipped the image you will need to display it. If you're working in a web environment, I would create a HTTP Handler to perform the flip and stream the resultant image to the browser. I've put together a small example which should help: class Program { static void Main(string[] args) { RotateClockwise(@"This is a test!").Save(@"C:\Test.gif", System.Drawing.Imaging.ImageFormat.Gif); } /// <summary>Draws a string to an image and rotates the image 90 degrees</summary> /// <param name="text">The string to be rotated</param> /// <returns>An image containing the rotated text</returns> public static System.Drawing.Image RotateClockwise(string text) { System.Drawing.Image rotateImage = null; // Create a new bitmap using (System.Drawing.Bitmap rotateBitmap = new System.Drawing.Bitmap(100, 100)) { // Create an image from the bitmap rotateImage = System.Drawing.Image.FromHbitmap(rotateBitmap.GetHbitmap()); // Draw the string to the image using (System.Drawing.Graphics graphics = System.Drawing.Graphics.FromImage(rotateImage)) { graphics.DrawString(text, new System.Drawing.Font("verdana", 8), new System.Drawing.SolidBrush(System.Drawing.Color.Pink), 0, 0); } // Rotate the image rotateImage.RotateFlip(System.Drawing.RotateFlipType.Rotate90FlipNone); } // Return an image containing our rotated text return rotateImage; } }
-
c# execute file helpCheck out the Process class and it's Start method
-
Convert string to a string arrayHope this helps... string myString = "1:00 PM,2:00 PM,8:00 PM,9:00 PM"; string[] myStringArray; DateTime[] myDateArray; // Split myString into an array myStringArray = myString.Split(new char[] { ',' }); // Create an array to hold our times myDateArray = new DateTime[myStringArray.Length]; // Step through our string array and create the times for (int index = 0; index < myStringArray.Length; index ++) myDateArray[index] = DateTime.Parse(myStringArray[index]);
-
Making string HTML compliantCheck out System.Web.HttpServerUtility.HtmlEncode(string) Hope this helps
-
Reading data from a .rar formatted fileAre you trying to save the .rar file to SQL or the compressed files in the .rar file?
-
DatesAlright mate, not sure I understand your problem but hopefully the code below will help. DateTime startOfMonth = DateTime.Now.AddMonths(1); startOfMonth = startOfMonth.AddDays(-startOfMonth.Day + 1); The code add's one month to the current date and then defaults the date to the 1st of the month.
-
empty textBoxesI use code like the following to set control's to their default values. You can either pass in the tab page to the function or modify it slightly and pass in the tab control and step through the control's pages. private void ClearTextBoxes (Control parentControl) { // Step through each control in the parent control and clear it's text if a textbox foreach (Control control in parentControl.Controls) { if (control is System.Windows.Forms.TextBox) control.Text = string.Empty; } } This method has the added advantage that you can also default check boxes' and other controls' properties by adding an additional if (control is [control type]) statement in the for loop. Hope this helps Aaron
-
Calling C# function within Browser ControlI can think of two possible solutions to your problem. The first is to hook-up an event handler for the browser control's BeforeNavigate2 event. You can then use this to parse special commands passed in the SRC attribute and execute particular methods. An example is shown below. HTML: Calls Host Form's MyCommand Method C#: private void WebBrowser_BeforeNavigate2(object sender, AxSHDocVw.DWebBrowserEvents2_BeforeNavigate2Event e) { // Determine if this is a proper url or a command if (((string)e.uRL).IndexOf("command:") != -1) { // Call the appropriate function for the command switch (((string)e.uRL).Replace("command:", "")) { case "mycommand": this.MyCommand(); break; } // Stop the browser from performing the navigation e.cancel = true; } } The other method is to hook up some event sinks to capture the DHTML events. Hope this helps. Aaron
-
Hexa ConvertingNot too sure what your question means but to display an int in Hex, you can use the ToString() method as below. As for converting a string to Hex, I don't quite understand what you mean. int convertMe = 102; string converted = convertMe.ToString("X");
-
How to find out if a file is local or from the networkOne possible solution is to use the WIN32 API function GetDriveType. By passing in the drive as a string, the function will return the drive type as shown below. int nDriveType = GetDriveType("Z:\\"); if (nDriveType == DRIVE_REMOTE) MessageBox(NULL, "Network Drive", "Network Drive", MB_OK | MB_ICONINFORMATION); Hope this helps.