Who wrote this code?
-
modelTables.Single(kvp => kvp.Key == model.GetType()).Value.ForEach(mt => mt.BeginProgrammaticUpdate());
vs simply:modelTables[model.GetType()].ForEach(mt => mt.BeginProgrammaticUpdate());
Oh yeah, I did! :rolleyes: At least there's an assert that the key exists in the dictionary. Or equally amusing:(from rec in context.GetTable<T>() select rec).ForEach(m => AppendRow(dv, (T)m));
vs.context.GetTable<T>().ForEach(m => AppendRow(dv, (T)m));
:rolleyes: :rolleyes:Latest Article - Building a Prototype Web-Based Diagramming Tool with SVG and Javascript Learning to code with python is like learning to swim with those little arm floaties. It gives you undeserved confidence and will eventually drown you. - DangerBunny Artificial intelligence is the only remedy for natural stupidity. - CDP1802
-
modelTables.Single(kvp => kvp.Key == model.GetType()).Value.ForEach(mt => mt.BeginProgrammaticUpdate());
vs simply:modelTables[model.GetType()].ForEach(mt => mt.BeginProgrammaticUpdate());
Oh yeah, I did! :rolleyes: At least there's an assert that the key exists in the dictionary. Or equally amusing:(from rec in context.GetTable<T>() select rec).ForEach(m => AppendRow(dv, (T)m));
vs.context.GetTable<T>().ForEach(m => AppendRow(dv, (T)m));
:rolleyes: :rolleyes:Latest Article - Building a Prototype Web-Based Diagramming Tool with SVG and Javascript Learning to code with python is like learning to swim with those little arm floaties. It gives you undeserved confidence and will eventually drown you. - DangerBunny Artificial intelligence is the only remedy for natural stupidity. - CDP1802
Marc Clifton wrote:
At least there's an assert that the key exists in the dictionary.
You'll get a different exception, but you will get an exception in both cases if the key doesn't exist. :) But the first version has the added advantage of iterating over the entire dictionary, and calling
model.GetType()
once for every single item within it. Probably not a huge issue, but not the best for performance. Alsofrom x in collection select x
seems to be fairly common with novice LINQ developers. :-D
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
-
modelTables.Single(kvp => kvp.Key == model.GetType()).Value.ForEach(mt => mt.BeginProgrammaticUpdate());
vs simply:modelTables[model.GetType()].ForEach(mt => mt.BeginProgrammaticUpdate());
Oh yeah, I did! :rolleyes: At least there's an assert that the key exists in the dictionary. Or equally amusing:(from rec in context.GetTable<T>() select rec).ForEach(m => AppendRow(dv, (T)m));
vs.context.GetTable<T>().ForEach(m => AppendRow(dv, (T)m));
:rolleyes: :rolleyes:Latest Article - Building a Prototype Web-Based Diagramming Tool with SVG and Javascript Learning to code with python is like learning to swim with those little arm floaties. It gives you undeserved confidence and will eventually drown you. - DangerBunny Artificial intelligence is the only remedy for natural stupidity. - CDP1802
So you were looking for models that are single you old cad:
Quote:
modelTables.Single
-
modelTables.Single(kvp => kvp.Key == model.GetType()).Value.ForEach(mt => mt.BeginProgrammaticUpdate());
vs simply:modelTables[model.GetType()].ForEach(mt => mt.BeginProgrammaticUpdate());
Oh yeah, I did! :rolleyes: At least there's an assert that the key exists in the dictionary. Or equally amusing:(from rec in context.GetTable<T>() select rec).ForEach(m => AppendRow(dv, (T)m));
vs.context.GetTable<T>().ForEach(m => AppendRow(dv, (T)m));
:rolleyes: :rolleyes:Latest Article - Building a Prototype Web-Based Diagramming Tool with SVG and Javascript Learning to code with python is like learning to swim with those little arm floaties. It gives you undeserved confidence and will eventually drown you. - DangerBunny Artificial intelligence is the only remedy for natural stupidity. - CDP1802
-
Marc Clifton wrote:
At least there's an assert that the key exists in the dictionary.
You'll get a different exception, but you will get an exception in both cases if the key doesn't exist. :) But the first version has the added advantage of iterating over the entire dictionary, and calling
model.GetType()
once for every single item within it. Probably not a huge issue, but not the best for performance. Alsofrom x in collection select x
seems to be fairly common with novice LINQ developers. :-D
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
Richard Deeming wrote:
Also
from x in collection select x
seems to be fairly common with novice LINQ developers.And when I wrote that, I definitely was. Still learning actually. Just now re-discovered that
Select
has version that includes the index!Latest Article - Building a Prototype Web-Based Diagramming Tool with SVG and Javascript Learning to code with python is like learning to swim with those little arm floaties. It gives you undeserved confidence and will eventually drown you. - DangerBunny Artificial intelligence is the only remedy for natural stupidity. - CDP1802
-
So you were looking for models that are single you old cad:
Quote:
modelTables.Single
RickZeeland wrote:
So you were looking for models that are single you old cad:
As of June 24th, 2018, not any more! ;)
Latest Article - Building a Prototype Web-Based Diagramming Tool with SVG and Javascript Learning to code with python is like learning to swim with those little arm floaties. It gives you undeserved confidence and will eventually drown you. - DangerBunny Artificial intelligence is the only remedy for natural stupidity. - CDP1802
-
My favorite columnist, the late Paul DiLascia used to write in the header of his code, "If this code works it was written by Paul DiLascia. If not, I don't know who wrote it."
Rick York wrote:
"If this code works it was written by Paul DiLascia. If not, I don't know who wrote it."
An a shorter version: "If this code works, it wasn't written by you!" ;)
Latest Article - Building a Prototype Web-Based Diagramming Tool with SVG and Javascript Learning to code with python is like learning to swim with those little arm floaties. It gives you undeserved confidence and will eventually drown you. - DangerBunny Artificial intelligence is the only remedy for natural stupidity. - CDP1802
-
RickZeeland wrote:
So you were looking for models that are single you old cad:
As of June 24th, 2018, not any more! ;)
Latest Article - Building a Prototype Web-Based Diagramming Tool with SVG and Javascript Learning to code with python is like learning to swim with those little arm floaties. It gives you undeserved confidence and will eventually drown you. - DangerBunny Artificial intelligence is the only remedy for natural stupidity. - CDP1802
So that must be:
Quote:
Love and marriage, love and marriage They go together like a horse and carriage This I tell you, brother You can't have one without the other
Congratulations !