|
Having been a developer for over 20 years, and a SQL DBA and Administrator since 6.5. My Preference is to design the database using Management Studio. I do it this way
#1. Design the raw tables include the fields for the Foreign keys BUT do not link them yet
#2. Design your Clustered indexes I will name them IDX_tablename
#3. Be lazy and use the Database Diagrams tool to define your Foreign Keys
My reason for doing this if the DB is designed correctly your app will be far more stable. If you design your foreign keys first it becomes your clustered indexes and normally you will cluster on a name or account number and not the ID.
|
|
|
|
|
Thanks for shared your experience David Johnson. its nice to know that
|
|
|
|
|
Code first is just for people that don't understand databases.
|
|
|
|
|
Hi
Is there a command to select all text on console window screen?
I would like to copy the last screen of text on the console window and save in a text (.scr)file
Manually I use Alt + spacebar, E, S to select all and right click the mouse to copy.
I run a program in Visual Studio which displays in a console window.
Numerous times text is printed to the screen, used and cleared.
The last screen of text contains useful information, saved as a script file, and run in a CAD program to draw cabinets and parts.
Manual keyboard shortcuts work. A "command" to do the same function would be nice.
|
|
|
|
|
If this is your own program then write everything to a file as you read it or display on the screen. If it is an app that you do not have the source for then you can redirect all output to a file quite simply with the > operator.
|
|
|
|
|
Provided you can find the process (which isn't complicated even if you didn't launch it) you can use SendKeys to send the CTRL+A, CTRL+C combination to the console app.
AFAIK, there isn't a way to "just read the text" from a generic console window after it has been written there.
This may help: https://dzone.com/articles/automatically-send-keys-other[^]
Sent from my Amstrad PC 1640
Never throw anything away, Griff
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Add some smarts to redirect console output as required.
Console.SetOut(TextWriter) Method (System) | Microsoft Docs
Note that you can then read your own console output if need be (if you redirect to a file).
The Master said, 'Am I indeed possessed of knowledge? I am not knowing. But if a mean person, who appears quite empty-like, ask anything of me, I set it forth from one end to the other, and exhaust it.'
― Confucian Analects
|
|
|
|
|
CTRL-A is supposed to select all text in a control or context in Windows. However, it doesn't seem to work in either the PowerShell window or Windows Terminal. I would be very curious about a solution as well.
|
|
|
|
|
CTRL-A is commonly used to select all text, but it must be implemented by the application itself. It works fine in a cmd window, but powershell ISE/console seems not to work.
|
|
|
|
|
Just did an experiment. I opened CMD.exe and CTRL-A worked. Then I typed powershell.exe and powershell opened in the CMD.exe window. CTRL-A no longer works. Exit powershell to CMD.exe and CTRL-A works again. So PowerShell is eating CTRL-A and not doing anything with it.
|
|
|
|
|
The reverse also applies - open Powershell, Ctrl+A doesn't work; run cmd.exe , and Ctrl+A works; exit back to Powershell, and it stops working again.
I haven't tried in the new Windows Terminal[^] to see if it's been fixed.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Wow you guys are fast.
This is my own program. I can look into using SendKey and TextWriter.
I might use TextWriter when I start to write the last screen of text or
possibly SendKey when the last screen is printed.
Sure appreciate it.
for console window, to select all, first set up your properties
Alt + spacebar (shows the dropdown menu)
P (to choose Properties)
Options tab- check Quick Edit Mode and Insert Mode
Alt + spacebar, E (for Edit), S (for Select All)
right click mouse (to copy to clipboard)
If you want to paste at command prompt- copy the command- in console window, right click to paste at command prompt.
Again, thanks
|
|
|
|
|
That description sounds more like a Windows Form application than a Console. Perhaps you should switch to a framework that makes the use of those features easier.
|
|
|
|
|
Is the console window part of your own app or is it an external to your app?
|
|
|
|
|
I wrote a program in C# that runs in Visual Studio as a console application.
When I run the program, in debug, it runs in a console window.
|
|
|
|
|
OK, so then why are you trying to copy'n'paste your own window text?
You're going to have to rethink your code and write a module that can write the required text to both the console window and to the file you want to capture the data to.
|
|
|
|
|
I change over to using StreamWriter. I have used it before, I wasn't thinking.
using System.IO;
using (StreamWriter list = new StreamWriter("C:\\Users\\Gene\\Desktop\\Test.scr", true)) {
list.WriteLine("Line " + cabinetx + "," + topy + " @" + cabinetWidth + ",0\n");
}
I changed from Console.WriteLine( ) to list.WriteLine( )
Works great. Beautiful thing. It doesn't print to screen but it does write to a text file.
I use progeCad. (similar to AutoCad)
I saw this online. Running script in Cad program
It draws a 1" square box. And it did it all in 1 line of code.
Line 0,0 @1,0 @0,1 @-1,0 close
Starts a line command. Space is like hitting the spacebar or Enter key.
Where do you want to start from? x,y coordinate 0,0. Space
What's the next point? @1,0. Space. and so forth
After that, I drew a cabinet, used it as a model to gather locations and sizes of Left end, right end, top, deck and measured for precise locations and sizes.
From those measurements I typed out these commands
Rectangle 0,4 @0.75,30.5
Rectangle 30,4 @-0.75,30.5
Rectangle 0.75,34.5 @28.5,-0.75
Rectangle 0.75,4 @28.5,0.75
Saved as a script file (.scr) and ran in progeCad as script file
It drew out in a split second what I had drawn previously for a model
After that, it was like candy. What other parts can I draw?
The program is two parts
First part gathers information- width, height, depth. Top drawer and 1 door, with 2 adjustable shelves. This is done thru user input, to change location, sizes and choice of parts.
Numerous windows display, allowing changes. Window is cleared and the next window is diplayed...
Second part is where all the commands code is generated. (similar to lines of code above)
I copy the command codes, paste in a text file, save as script file and run in progecad
Each line, represents one full command in progeCad. The first line runs and jumps to the next line until the end. It just drew several views of the cabinet.
Using StreamWriter, no more copy and pasting.
Thanks again.
|
|
|
|
|
OK, so what's wrong with adding a Console.Write immediately after your write to the file?
using (StreamWriter list = new StreamWriter("C:\\Users\\Gene\\Desktop\\Test.scr", true)) {
string content = "Line " + cabinetx + "," + topy + " @" + cabinetWidth + ",0\n";
list.WriteLine(content);
Console.Write(content);
}
|
|
|
|
|
I need to save the text that comes up on the last screen displayed.
It's the whole purpose of the program, to generate the text displayed on the last screen.
I don't need to see it. I do need to copy and paste it.
Before, I have printed the text to the last screen for one reason.
To select all- and copy to clipboard then to paste and save in a text document.
I needed it displayed so I could copy it.
Now, using StreamWriter, that information is written to a text file and saved
I no longer have to copy and paste. I don't need to see it.
And if I want to see the text from the last page, I can open the text file. It's an exact copy
There are several hundred lines I need to change from Console.WriteLine to list.Writeline
I have changed several methods that are writing to the text file. It's working as expected. Thanks
modified 10-Sep-19 22:10pm.
|
|
|
|
|
Greetings all - first time poster here, so please forgive me if I've submitted this incorrectly
A user selects from a list of enum. I want that enum to be the actual name of a var. Then I'd like to use (some kind of placeholder argument in a method), to call that selected enum and evaluate the method. Here is the relevant example section:
{
public enum Fruit
{
Apple, Orange
}
[Parameter("Fruit Type")]
public Fruit FruitType { get; set; }
public override void Calculate
{
var Apple = 5
var Orange = 1
bool MoreApples = Apple > Orange;
bool FewerApples = Apple < Orange;
if (FruitType == Fruit.Apple && MoreApples)
{
}
if (FruitType == Fruit.Orange && FewerApples)
{
}
Is there some better way to assign the enum to a var (or other way around??), and then have a Method call the chosen enum, and return the actual bool data in order to see if the IF is satisfied? Perhaps this is an array thing?
I was hoping to use something like: FruitType == Fruit.XXX, with XXX pulling selected enum.
Thank you all for helping the C# newbie -
|
|
|
|
|
Quote: I want that enum to be the actual name of a var.
Nope. You don't get to do that. The values in an enum should not be thought of as variable names at all. Expanding that a little, if you have a string variable with the name of a variable as its value, that's also wrong.
It may work in interpreted languages, but it doesn't work in compiled languages. The variable names no longer exist(*).
* There is, of course, an exception. The namespaces, classes, method names, variables, and other code objects/names ARE available as metadata in .NET code. You access that data through the System.Reflection classes. Using reflection in your code will WAY over-complicate your code and reduce its performance. Reflection is not a quick thing. Don't do it unless you have a very specific reason and no other options.
In your example, your Calculate method should accept a parameter, FruitType. You don't appear to need the property at all. Of course, this makes assumptions that you don't show in your code nor explain in your question.
public override void Calculate(FruitType fruitType)
A method with the name Calculate also suggests it should return a value, which your code doesn't.
|
|
|
|
|
Dave Kreskowiak wrote: ... values in an enum should not be thought of as variable names at all ... It may work in interpreted languages, but it doesn't work in compiled languages. The variable names no longer exist(*). Hi, Dave, I take exception to this conclusion in the limited sense that we can use Enum values as variables which function as indexes to deferred execution code, as shown in my response on this thread.
«One day it will have to be officially admitted that what we have christened reality is an even greater illusion than the world of dreams.» Salvador Dali
|
|
|
|
|
While you are correct, I limited my answer to the context of "beginner". Yeah, it's a little white lie, for the sake of simplicity and learning the basics first.
|
|
|
|
|
Dave Kreskowiak wrote: context of "beginner" good point, Dave ! I've added a second reply here showing use of a 'switch statement ... hope it be useful to the OP.
«One day it will have to be officially admitted that what we have christened reality is an even greater illusion than the world of dreams.» Salvador Dali
|
|
|
|
|
Dave -- Thank you VERY much for the explanation-
I am such beginner, I am having trouble knowing what I yet don't know (which is mostly everything).
1) a user selectable list of things (enums - or some other way?)
2) var(s) initialized that calculate something
3) an IF that wants to evaluate whether some var && some other var are true), and if so, do something.
as it is now, I have to hard code all possibilities for each if (of each selected enums) using the vars directly. What I'd like is a way to have the user selected choice populate the iF with the appropriate var - that would alleviate hard coding each and every possibility.
Am I even phrasing the question properly? probably not -- And if not, can you point me to an area I should study as to be better informed about syntax and possibilities? If I am way off, many apologies...
Thanks so much again for your help-
|
|
|
|
|