|
After 3 hours and 11 minutes I think I've finally understood what's going on in your example...
The first thing that threw me was "LambdaExpression le = Expression.Lambda(me, "CompanyName");" as the compiler wanted a parameter expression rather than a string passing in - easily fixed.
The real head scratcher, however, was "c" (as in c.ElementType and c.Provider.CreateQuery(mce)) - what the heck was c? The compiler sure didn't know, and wasn't offering much help either. It occurred to me to wonder what the IQueryable queried was expecting to be filled with, and learned that I needed a set of data, in my case a List of models, AsQueryable. Success!
One question remains which I've not been able to answer...
I take it IQueryable queried actually holds all of the results of the query, however when i try to cast it back to a List < Model > , I end up with an empty list... what am I doing wrong?
"On one of my cards it said I had to find temperatures lower than -8. The numbers I uncovered were -6 and -7 so I thought I had won, and so did the woman in the shop. But when she scanned the card the machine said I hadn't.
"I phoned Camelot and they fobbed me off with some story that -6 is higher - not lower - than -8 but I'm not having it."
-Tina Farrell, a 23 year old thicky from Levenshulme, Manchester.
|
|
|
|
|
Martin, LINQ uses deferred processing, so it's not actually evaluated until you try to do something with it. To this end, you can use
List<Model> model = queryable.ToList<Model>();
|
|
|
|
|
Thanks for that Pete - i think I have a much better (and yet still tenuous) grasp on the whole she-bang now... I shall have to tinker some more!
"On one of my cards it said I had to find temperatures lower than -8. The numbers I uncovered were -6 and -7 so I thought I had won, and so did the woman in the shop. But when she scanned the card the machine said I hadn't.
"I phoned Camelot and they fobbed me off with some story that -6 is higher - not lower - than -8 but I'm not having it."
-Tina Farrell, a 23 year old thicky from Levenshulme, Manchester.
|
|
|
|
|
No bother bonny lad. This[^] is the book I've been using to get my head around LINQ, I can't recommend it highly enough.
modified on Monday, December 17, 2007 4:32:23 PM
|
|
|
|
|
Could someone clear something up for me...
I'm trying to figure out how to work with filepaths on both Linux and Windows.
If I create a string like the one below, it will work on Windows but not on Linux because of the backslashes.
string s = Application.StartupPath + @"\config\settings.txt";
Would I get the correct path on both operating systems if I use this:
string s = Path.GetFullPath(Application.StartupPath + @"\config\settings.txt");
Or do I have to parse the string manually by using "DirectorySeparatorChar"?
|
|
|
|
|
Hi,
I have not done this but I think it is wise to avoid all backslashes, either by
using several Path.DirectorySeparatorChar or several Path.Combine()
|
|
|
|
|
I managed to get OpenSuse up and running with Mono so I could run some tests.
I ran the code below with "test1.txt" in application folder and "test2.txt" in a folder called "folder1" under application folder
char sep = Path.DirectorySeparatorChar;
string path1 = Application.StartupPath + "\\test.txt";
string path2 = Path.GetFullPath(path1);
string path3 = Path.Combine(Application.StartupPath, "test.txt");
string path4 = Application.StartupPath + sep + "folder1" + sep + "test2.txt";
richTextBox1.Text = path1 + Environment.NewLine + path2;
richTextBox1.Text += Environment.NewLine + path3 + Environment.NewLine + path4;
richTextBox1.Text += Environment.NewLine + Environment.NewLine;
StreamReader sr = new StreamReader(path3);
string text = sr.ReadToEnd();
sr.Close();
richTextBox1.Text += text;
sr = new StreamReader(path4);
text = sr.ReadToEnd();
sr.Close();
richTextBox1.Text += Environment.NewLine + text;
On Linux, the result was this:
/home/mono/Desktop/PathTest/PathTest/bin/Debug\test.txt
/home/mono/Desktop/PathTest/PathTest/bin/Debug\test.txt
/home/mono/Desktop/PathTest/PathTest/bin/Debug/test.txt
/home/mono/Desktop/PathTest/PathTest/bin/Debug/folder1/test2.txt
This is the text in test1.text
This is the text in test2.text
And on windows, the result was this:
C:\Documents and Settings\Johan\Desktop\PathTest\PathTest\PathTest\bin\Debug\test.txt
C:\Documents and Settings\Johan\Desktop\PathTest\PathTest\PathTest\bin\Debug\test.txt
C:\Documents and Settings\Johan\Desktop\PathTest\PathTest\PathTest\bin\Debug\test.txt
C:\Documents and Settings\Johan\Desktop\PathTest\PathTest\PathTest\bin\Debug\folder1\test2.txt
This is the text in test1.text
This is the text in test2.text
So the conclusion of this, as you pointed out, using Path.DirectorySeparatorChar or several Path.Combine() is the way to go.
Using Path.GetFullPath did not correct a windows-formated path as I thought.
Thanks for your help.
|
|
|
|
|
How to rotate a text/image automatically from left side to right side in form or vice versa
I use adrotator in case of image, but the image is not rotating .it is fixed in position.
and also in case of label(text).
How can i do this ?
thanks
|
|
|
|
|
anupamwb wrote: I use adrotator in case of image, but the image is not rotating .it is fixed in position.
I don't think that you mean the same thing by "rotating" in this case. When ads are rotated, they are simply show one at a time.
When graphically displaying text or images, rotating means that you rotate the object around a fixed point. You seem to rather be looking for "moving" than "rotating", is that right?
Experience is the sum of all the mistakes you have done.
|
|
|
|
|
Yes,u r right, term should be "moving" .
the text /image should be automatically moving from one side to another side of form when loading.this moving should be continious.
i used adrotator but did not get result.
|
|
|
|
|
Hi,
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;
}
}
|
|
|
|
|
Hello All
I am trying to catch a right button down event for a control before the form sends it to this control; I tried to do that through overriding the WndProc
But it fails!
Is there any way to do that?
|
|
|
|
|
|
Hi gurus,
I must develop a software which lets the end-user design his own form and fill it afterwards. In the other hand the user will define the form's structure (simple or master/detail) and starts entering data in it. I'd like to know that from your point of view what is the best architecture/design for such a program. Specially what is the best way to persist entities inside DB.
Thanks alot
Aref , MCTS & MCPD
|
|
|
|
|
A question:
"Why do you want to allow users to ruin design a form?"
arefkarimi wrote: Specially what is the best way to persist entities inside DB
"Send your users on a database methodology and design course"
In all seriousness users are just that "users" - which means that they use systems which we as IT professionals create for them.
Allowing users to move fields around on a from is a different matter, however allowing them to have so much control that they could compromise the database integrity (which is what I'm guessing you mean by "best way to persist entities inside DB") is so so much a bad design idea.
Maybe if you gave more background...
Barring that I would suggest an interface such as Microsoft Access as it probably is one of the simplest form design interfaces I have encountered.
You always pass failure on the way to success.
|
|
|
|
|
Hi GuyThiebaut,
Thanks for the reply. First I must say that I dont want to write this program by my wish! The company in which I work have an old product line (written by Delphi) and a new .NET product line. In the Delphi product line there is such a program (we call it Form Maker) and I must say that our end users love it! They love it because they can extend the system's forms or they can add their desired forms. for example in Office Automation system, there is a Letter form. In some cases, some kind of letters have some information which our Letter form doenst support them. So the users can design an extra Letter form and attach it to the main Letter form. Or in some cases some users need to enter some data and make reports out of them but our total system doenst contain such a feature. For instance suppose that our integrated system has Accounting and Inventory programs but no Appointment system. By our Form Maker the user can design his own Appointment form in a few minutes and use it. Our Form Maker can only save and load data and there is no complex business supported in it.
As I mentioned, our Delphi systems has a Form Maker program. This program lets the user design the forms and then based on the structure of each form it creates some DB objects (i.e. Tables, Indcices...). When I was asked to write it in .NET I tough I would better search for better ways (better architecture or design) and not to rewrite the same thing in .NET. When I said "persisting entities" I ment to keep them somewhere, not DB only.
I googled in web and I found out that there are alot of Form Makers on the globe
Thanks again
Aref, MCTS and MCPD
|
|
|
|
|
Hi Aref,
Thanks for such a detailed response.
It looks to me like you need to buy some third party software for this.
Developing this yourself would be a very large task (you would probably need a team of developers to realise this sort of project in a reasonable time).
I'm sure there are applications out there which will do this (I have come across Delphi applications(which you mention)).
All I can say is, unless anyone else on this forum is able to give you some direction, google and you should find developer tools/applications addons that will do this.
Sorry I could not be of more help.
Good luck.
Guy
You always pass failure on the way to success.
|
|
|
|
|
How can I use delayed clipboard rendering (just some text) in C# ?
|
|
|
|
|
Methinks you'll need to SetClipboardData() with null data (i.e. just register the clipboard format) and then handle the WM_RENDERFORMAT and WM_RENDERALLFORMATS messages.
/ravi
|
|
|
|
|
I am loading up DataSets which use about 2GB of memory. My memory usage shows aproximately .5GB at start, then as it allocates space for the DataSets I show 2 GB being uses, I then get an error message saying I am out of memory yet I still have 1.5GB left. I have eliminated the possibility that the method is not working correctly.
Does anyone have any ideas on how to proceed or what the problem may be.
Michael
|
|
|
|
|
Why are you trying to put such a massive amount of data into memory?
|
|
|
|
|
Load Testing on Memory?
Vasudevan Deepak Kumar
Personal Homepage Tech Gossips
A pessimist sees only the dark side of the clouds, and mopes; a philosopher sees both sides, and shrugs; an optimist doesn't see the clouds at all - he's walking on them. --Leonard Louis Levinson
|
|
|
|
|
Is this a 32 bit or 64 bit application? A 32 bit application can't address more than 2 GB of memory.
Experience is the sum of all the mistakes you have done.
|
|
|
|
|
Hi, all.
If anyone knows of any articles or web sites that go into detail of a 'high score system' or internet usage (like a simple multiplayer game where you can chat) I'd be greatly appreciative. Also, if anyone could tell me how to publish a program... Step 1) Zip up contents - what are all the contents? Step 2) eMail content???
Thanks!
- I love D-flat!
|
|
|
|
|
Hich scores can be stored whereever you like, the registry, XML, a flat file. It's up to you. Any internet based stuff is going to revolve around a central server that at a minimum acts as a hub to allow players to find each other, even if traffic after that goes direct between the players.
To deploy a program, you're better off creating an installer, which also means it can enforce the need for the .NET framework.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|