|
First, I'm not reading it like that - use the code block (<pre> tags) to preserve the formatting so the code is readable.
Then, explain you problem in reasonable detail in the question, instead of in the title - remembering that we can't see your screen, access your HDD, or read your mind.
Explain what you are having problems with - what the code does and doesn't do, and why. At the moment, you've just dumped some code on us and said "fix this".
Help us to help you!
Those who fail to learn history are doomed to repeat it. --- George Santayana (December 16, 1863 – September 26, 1952)
Those who fail to clear history are doomed to explain it. --- OriginalGriff (February 24, 1959 – ∞)
|
|
|
|
|
I inherited an app that was created using EF6 - Model First. How do I update the database after making modifications to the tables? If it was code first I could use migrations to handle it, but I'm hesitant to try that with this model.
|
|
|
|
|
I think you need to clarify your terminology.
The "tables" ARE the "database".
Did you modify the "database" and now want to update the "model"? In which case, you open the ".edmx", right-click the design surface, and then click "Update model from database...".
... Backing up your project first, of course.
modified 25-Jul-14 19:49pm.
|
|
|
|
|
Doesn't that drop all the tables and their data?
|
|
|
|
|
Why would you think what I suggested "drops the tables ...".
The "model" is the "code".
"Update model from database..." READS the database schema and updates the "classes" that define the "entities" in the "model".
|
|
|
|
|
I am consolidating about 10 databases into one. I have ran across multiple cases in the older databases where they have a combo-box linked to a database table with under 10 items. What would be the best way to handle the small amount of data ? Do I create a strongly typed array or do I keep the 20 different tables that will never have any data added ?
|
|
|
|
|
Sounds like the tables might be holding enumeration types values. If so, they're probably anchored by foreign keys on other tables. Do they have just two columns, a key and a value?
It's a common problem, because in code you might use an enum to represent these values and you end up in the situation of how to keep the database and code in sync.
You could remove the tables, but that might render the database a bit meaningless without the application tier in place, limiting what could be achieved via a stored proc for instance. You can't really create enum types at runtime, although you could create the same effect using static members on a class.
Probably the best way would be to have them as a collection of key/value pairs.
I can't really offer a definitive answer I'm afraid, but for completeness it might be advisable to keep them.
Regards,
Rob Philpott.
|
|
|
|
|
I have jumped both way in the past, leave multiple emun tables or stick them into a single key/value table. I find the multiple table solution the best mainly for the FK constraint capability.
I also use my code generator to create the enum values in the application in a class called... Enums - go figure!
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Mycroft Holmes wrote: I also use my code generator to create the enum values in the application
That has been my solution in the past too!
Avoids all that nasty ORM stuff. Also getting it to do a runtime check that things are aligned is useful, in case someone in their wisdom decides to reassign the enums..
Regards,
Rob Philpott.
|
|
|
|
|
Mycroft Holmes wrote: a single key/value table
I have only done that sort of thing once, but it's really only to provide translations when reporting.
But in general, it sounds like a bad idea if you are relying on the table for referential integrity.
You'll never get very far if all you do is follow instructions.
|
|
|
|
|
The problem that I find with enums is you may not be adding stuff to them but what happens if you remove an item? The rest of the items move up in the numbering scheme unless you explicitly provide the values of each enum member. If you're using that value in a database, you'll be changing the meaning of all of your stored values by adding/removing a single line of code in your enum definition.
Using an auto numbering enum may look good up front, but can bite you in the ass later on when adding/removing members to them.
|
|
|
|
|
Dave Kreskowiak wrote: The rest of the items move up in the numbering scheme unless you explicitly provide the values of each enum member
You only ever get bitten by this once, then you dig into your code generator and explicitly number the items
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Fortunately this has never happened to me because I saw the problem before I even wrote any code.
Other people I've worked with in the past, however, didn't see the problem even after their applications starting crapping all over themselves. Ask them what they changed and it's always "nothing" and then 20 minutes later the truth comes out and they changed and auto enum.
Enums are very simple things to understand but yet extremely difficult for some people for some reason.
|
|
|
|
|
For what it's worth - the way I set up drop down values is in one database table.
Below is an over-simplified example.
Doing this allows me to manage all the dropdowns, irrespective of application and control, for the whole ERP system within one reference table:
id application control_name item active position
17 proj proj_cmb Tier1 1 1
18 proj proj_cmb Tier2 1 2
19 proj proj_cmb Tier3 1 3
“That which can be asserted without evidence, can be dismissed without evidence.”
― Christopher Hitchens
|
|
|
|
|
That concept is seductive, I had not considered it across apps, but I like my FKs too much to do that. We do 90% of our processing in the database so that always gets first consideration, nature of the beast (not ERP).
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
As our ERP system grew, which is written in house (previously with the lead developer and me but now solely by me) we decided to split the different areas of the ERP into separate applications in order to make development/maintenance easier(the users did not appear to mind).
From the very early days I started shifting hard-coded lists, within the UI code, out into the back-end database. I have also written some tools to help me administer this database.
In practise what this means is that I can make quick changes to lists within applications without having to roll out new releases to users.
The example I gave above is an over-simplified version of what I have built.
The reference table, for lists, also allows stored procedures to be used for populating lists(with parameters being supplied from the client side) and even allows cascading dropdown design (e.g. country and state dropdowns).
This has made my life so much easier, so I can concentrate on developing new features rather than spending hours on amending the contents of dropdowns.
“That which can be asserted without evidence, can be dismissed without evidence.”
― Christopher Hitchens
|
|
|
|
|
Thanks you guys are awesome
|
|
|
|
|
Unless there is a compelling reason to combine them, I'd keep the tables separate.
As others have also said, I can generate an enum from them. GenOmatic[^]
You'll never get very far if all you do is follow instructions.
|
|
|
|
|
Hi All,
I use the rdcl report with c# web application and I have a 2 questions:
1. Is it possible to create the rdcl report with dynamic dataset.xsd, if yes how?
2. Is it possible to show the rows as header columns as the following:
we have Customers datatable with columns ID,Name and by default shown like this,
ID Name
1 zead
2 jan
but the customers datatable columns not have a static columns ID,Name..
it may be contains city, address, phone
(dynamic columns).
Please help me ASAP
|
|
|
|
|
|
Greetings,
I'm using a crystal report and using it to make a sales report and I want to sort the reports displayed based on the date of the sales order what I should do I create a parameter field and its type is Boolean what else I should do what is the formula to write to do such sorting
|
|
|
|
|
|
As an alternative to the other suggestion you might consider retrieving the data from the data store so it is already sorted.
|
|
|
|
|
Hey, I am trying to make an application that allows me to connect to a proxy server through a c# console application but I am not sure how.What I want to achieve is the program selects a random IP from the list in a text file and opens up google using the chosen proxy IP, I want to use it in school because the website restrictions are completely broken, most websites are blocked for either sales or occult. I've been looking around on the web and I found a few things like HttpWebRequest and HttpWebResponse but I don't know how to use it, could someone link me to a website that explains this kind of thing or explain it on here please.
I've got this but its probably completely wrong.
In ProxyIps.txt there is a large list of proxy IP addresses.
<br />
using System;<br />
using System.Collections.Generic;<br />
using System.Linq;<br />
using System.Text;<br />
using System.IO;<br />
using System.Net;<br />
<br />
namespace FirstWebProxy<br />
{<br />
class Program<br />
{<br />
static void Main(string[] args)<br />
{<br />
Console.WriteLine("Available proxys:");<br />
<br />
string[] lines = System.IO.File.ReadAllLines(@"C:\Users\user0\Documents\Visual Studio 2010\Projects\FirstWebProxy\ProxyIps.txt");<br />
<br />
foreach (string line in lines)<br />
{<br />
<br />
Console.WriteLine("\t" + line);<br />
}<br />
<br />
Console.WriteLine("Would you like to connect to a random server? Type Y or N");<br />
string r = Console.ReadLine();<br />
<br />
if (r =="Y" || r =="y") {<br />
<pre lang="cs">var p = new Random();<br />
var randomLineNumber = p.Next(0, lines.Length - 1);<br />
var host = lines[randomLineNumber];<br />
<br />
string url = "http://www.google.com/";<br />
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);<br />
WebProxy myproxy = new WebProxy(host, false);<br />
request.Proxy = myproxy;<br />
request.Method = "GET";<br />
HttpWebResponse response = (HttpWebResponse)request.GetResponse();<br />
}<br />
<br />
}<br />
}<br />
}<br />
<br />
Thanks in advance.
|
|
|
|
|
Member 10521793 wrote: but its probably completely wrong. Why do you think so? What does happen instead of what you expect to happen? Any error messages? Any missing functionality?
|
|
|
|