|
|
Thanks!
http://drsql.spaces.live.com/blog/cns!80677FB08B3162E4!766.entry[^]
My tendency is to use a join, so I found this comment especially useful:
[quote]
So in conclusion, the point of this post is to avoid using joins to try to compare two sets, since this is not its function. In the end the join method doesn't seem clear as to what you are asking. I only touched on performance, but the join will often peform worse than the using in or exists, simply because the work involved to do the join is greater.
[/quote]
[sigh] live and learn
|
|
|
|
|
ChrisC(@ncmail) wrote: will often peform worse
Test it.
ChrisC(@ncmail) wrote: the work involved to do the join is greater
Though that work may be beneficial in some cases.
|
|
|
|
|
Here's another good reason not to use reserved names.
I'm working on a LINQ project with a series of tables that manage user roles. As a result, I have table names like Systems, Roles and Users.
My trouble started when I would add the objects to the Designer, hit Save and then suddenly Visual Studio would say things like
System.Data.Linq.Mapping.DatabaseAttribute is not defined
or
System.Nullable is not defined
In short, stopping me dead in my tracks. Now that I look back, I don't know why I didn't see the reason earlier.
When using the Object Relational Designer, Visual Studio wants to be smart and changes any words that are plural to singular so they make more sense when dealing with data.
That way, your code looks like
<br />
oUser = New User<br />
oUser.UserName = "John"<br />
instead of
<br />
oUser = New Users<br />
This is really nice because it does make the code a little more legible except in this situation:
Plural (singular)
Users (User)
Roles (Role)
UserRoles (UserRole)
Systems (System)
See the gotcha? Visual Studio translated the "Systems" table into a "System" object which immediately negated all of the main namespaces in the project.
The renaming feature for the objects in LINQ-to-SQL is great - but be warned, when you start getting errors like this, take a look at your source tables.
|
|
|
|
|
This reminds me of, "automagically", in the Buzzwords Hall of Shame, and makes me wish you didn't like the feature; because auto-complete is good, but auto-editorialize is nonsense and dangerous, as you just illustrated. Programming != Word Processing.
Honestly Illustrated
<Pretentious> Raid tha manyuhl. :E
<Pretentious> Aw raid eh own mah meaxbile. :E
|
|
|
|
|
Had a similar problem few months ago. I had "Language" table in database basically storing all languages, that were used for multi-language stuff.
Then when database schema was finished, I began working on data access layer and DataSet designer failed miserably on that "Language" table. I don't recall what the problem was exactly, but the "Language" name was a no-no. Cheers
modified 19-Nov-18 21:01pm.
|
|
|
|
|
|
I may be wrong but I think there is an option to turn this "pluralization" behaviour off.
|
|
|
|
|
I think it should be an option to turn the feature on.
Honestly Illustrated
<Pretentious> Raid tha manyuhl. :E
<Pretentious> Aw raid eh own mah meaxbile. :E
|
|
|
|
|
_beauw_ wrote: but it is not the place of the Object/Relational Designer to enforce this.
That's why you can disable it: Model IDE->Properties->Pluralize New Objects
Please note that this is a pure religious issue: In my case, all my tables are singular names(Login, Person, Role, etc). So I would have had a table named "System" and without the pluralization on, I would have had to map them differently to avoid this collision. You can map the tables any way you like in EF4.
Fact is, you'll always run the risk of name collisions with any code generation.
Before .NET 4.0,
object Universe = NULL;
|
|
|
|
|
I once had this bad experience too, and at that time we noticed that having database tables with Portuguese names would solve the problem (although we might have had problems with pluralization/singularization...)
|
|
|
|
|
Hi, this is my post! :S
function GoPage(accion)
{
if(accion == "G")
window.location.href = 'resultadointerfaz.asp?vyear='+ document.getElementById('Select2').value+'&vmes='+document.getElementById('Select1').value+'&tipo='+document.getElementById('tipo').value+'&consultar=G';
else
window.location.href = 'resultadointerfaz.asp?vyear='+ document.getElementById('Select2').value+'&vmes='+document.getElementById('Select1').value+'&tipo='+document.getElementById('tipo').value+'&consultar=C';
}
What do you think. I think that the else is not necesary!
bye!
|
|
|
|
|
there is a 1-letter difference near the end!
|
|
|
|
|
Good spotting. I missed that.
|
|
|
|
|
yes there is =D
but the whole function could be written better, with regard to DRY
|
|
|
|
|
Since setting of href does not necessary stop the scripts and jump to new address, I think that else is required. But the code can be probably replaced with a single line like this:
window.location.href = "...&consultar=" + accion;
|
|
|
|
|
If action is, for example, 'X', your function works differently to the original
|
|
|
|
|
Obviously a genetic algorithm should be used to evolve the URL, why can't some programmers figure that out? >_>
|
|
|
|
|
|
I think:
function GoPage(accion)<br />
{<br />
if (accion == "G") { consultar_val = G; }<br />
else { consultar_val = C; }<br />
window.location.href = 'resultadointerfaz.asp?vyear='+document.getElementById('Select2').value+'&vmes='+document.getElementById('Select1').value+'&tipo='+document.getElementById('tipo').value+'&consultar='+consultar_val;<br />
}
Honestly Illustrated
<Pretentious> Raid tha manyuhl. :E
<Pretentious> Aw raid eh own mah meaxbile. :E
|
|
|
|
|
Controls' names Select1 and Select2 are another horror.
Greetings - Jacek
|
|
|
|
|
<select id="Select4"><option>Bad Idea></option></select>
<select id="Select2"><option>Bad idea></option></select>
<select id="Select7"><option>bad Idea></option></select>
<select id="Select5"><option>bad idea></option></select>
<select id="Select1"><option>BadIdea></option></select>
<select id="Select6"><option>badIdea></option></select>
<select id="Select3"><option>Bad_Idea></option></select>
<select id="Select8"><option>bad_idea></option></select>
Honestly Illustrated
<Pretentious> Raid tha manyuhl. :E
<Pretentious> Aw raid eh own mah meaxbile. :E
|
|
|
|
|
Or, simpler:
function GoPage(accion)
{
window.location.href =
'resultadointerfaz.asp?vyear=' +
document.getElementById('Select2').value +
'&vmes=' +
document.getElementById('Select1').value +
'&tipo=' +
document.getElementById('tipo').value +
'&consultar=' +
(accion == 'G' ? 'G' : 'C');
}
|
|
|
|
|
I wanted to use the ternary operator there, too; then I thought of the future case of adding a third "accion" and decided to leave an obvious ability to add an "else if" condition at the top.
Honestly Illustrated
<Pretentious> Raid tha manyuhl. :E
<Pretentious> Aw raid eh own mah meaxbile. :E
|
|
|
|
|
We all like Oracle, don't we:
CREATE TRIGGER "LOGIN_ID_TRG" BEFORE INSERT ON "LOGIN" REFERENCING OLD AS OLD NEW AS NEW FOR EACH ROW
DECLARE
v_newVal NUMBER(12) := 0;
v_incval NUMBER(12) := 0;
BEGIN
IF INSERTING AND :new.ID IS NULL THEN
SELECT Login_ID_SEQ.NEXTVAL INTO v_newVal FROM DUAL;
IF v_newVal = 1 THEN
SELECT NVL(max(ID),0) INTO v_newVal FROM Login;
v_newVal := v_newVal + 1;
LOOP
EXIT WHEN v_incval>=v_newVal;
SELECT Login_ID_SEQ.nextval INTO v_incval FROM dual;
END LOOP;
END IF;
:new.ID := v_newVal;
END IF;
END;
/
Does that gem do what it is expected to do?
Hm, the first row inserted into the (empty) table gets the ID 1 (and is inserted into the table with ID 1), but Login_ID_SEQ.curr_val is already 2, and consequently the C# application communicating with that Oracle db received a wrong value (it calls SELECT Login_ID_SEQ.CURRVAL FROM DUAL in order to get the last insert id). By the way, the second row inserted receives ID 3.
For the first value inserted into an empty table, the LOOP is executed once, and thus Login_ID_SEQ.nextval twice. Setting the start value of v_incval to 1 did the trick. But I fear the trigger will fail if some when a row would be inserted with an ID different from null (fortunately, we had not activated the IdentityInsert property in our SQL Server database, and hence I am confident that our application won't do that).
How did I find that gem? I used an Oracle tool to convert my SQL Server database. Then I wrote a script to set up all the tables, sequences, triggers, and some start values for my "schema" using the "Show SQL" feature of Oracle Enterprise Manager for each of these objects. Then I tested that with a fresh schema, and my application threw an error with the first login attempt. Thanks a lot, Oracle!
|
|
|
|