|
|
I took the lesson. Thank you.
|
|
|
|
|
I feel nice today, so I will help you once here, thats it though, next time, try the correct forum.
Harry Sun wrote: unsaved-value="0"
That seems like bogus.
|
|
|
|
|
Thanks for your kind. I removed that code you mentioned, but the problem still exists. In fact, I thought it is fine for define unsaved-value="0", because I have already make this attribute as incremental identiy in database. While debugging the code, the object which I intend to save in session.save(u) does have correct values. And it works fine if I just work with one table. Am I right? Please tell me if you got time.
|
|
|
|
|
You can't use user as a table name and have it work with NHibernate unless you do some special stuff in your mapping file...
In your user.hbm.xml do this:
//note the square brackets around the table name.
<class name="ConsoleApplication1.user, ConsoleApplication1" table="[user]">
That'll fix your problem...
Richard
http://www.BellaDev.net
|
|
|
|
|
Please check "Ignore HTML tags in this message" or do something about that <class..., it's not showing up
[ My Blog] "Visual studio desperately needs some performance improvements. It is sometimes almost as slow as eclipse." - Rüdiger Klaehn "Real men use mspaint for writing code and notepad for designing graphics." - Anna-Jayne Metcalfe
|
|
|
|
|
Dear Richard,
That is what the problem is. I really appreciate to what you did. It has been tough time for me. You saved me. Thank you again.
Harry
|
|
|
|
|
I learned from a senior system's analyst today that you should never pass a class you created back from a webservice. Since he was wanting to pass a dataset back and also the exception message if one occurred, he decided it was better to send back an empty dataset and have the webservice write a file to the users machine if it generated an error! Why couldn't I think of that!!!
|
|
|
|
|
jchigg2000 wrote: a senior system's analyst
I assume you mean that he was just old or out of touch. Why on earth does he think you can't pass a class back? More importantly, why's he passing a DataSet back? DataSets are really bad practice when you're developing a web service - they are bloated and not interoperable with other platforms without extra development effort. Mind you, there are so many WTFs in his solution that I can't begin to allude to the horror in it.
|
|
|
|
|
Pete O'Hanlon wrote: there are so many WTFs in his solution that I can't begin to allude to the horror in it
I ditto that.
"I guess it's what separates the professionals from the drag and drop, girly wirly, namby pamby, wishy washy, can't code for crap types." - Pete O'Hanlon
|
|
|
|
|
jchigg2000 wrote: a senior system's analyst
He might be a senior system analyst just by virtue of his experience in date and time calendar. But adjudging him through his wise (pros) and vices (cons) in programming, he should truly be classified as a junior most crap .
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
|
|
|
|
|
Hello folks!
I did a little spy-out (with Reflector(c)) the DataView-Class. And found the following:
public IEnumerator GetEnumerator()
{
DataRowView[] array = new DataRowView[this.Count];
this.CopyTo(array, 0);
return array.GetEnumerator();
}
Do I understand right: Each foreach-Initialisation it will copy all its Content to a new array, and return that arrays Enumerator??
And if I break the foreach-loop at second element all these DataRowViews came into live in vain?
|
|
|
|
|
Yeah, must be some old code.
Try not to use foreach if you expect to break the iteration.
|
|
|
|
|
PIEBALDconsult wrote: Try not to use foreach if you expect to break the iteration.
Thats the first time I hear this advice. It results in some little pretty ugly workarounds, doesn't it?
No - I expect the coders to make their enumerators efficient and keep on enjoing the better design of foreach (if available).
|
|
|
|
|
Actually, it's the result of one of the tenets of iteration development. If you have to use a break statement (or god forbid a goto) to get out of a loop, you are using the wrong type of loop. Have a look at Code Complete by Steve McConnell to find more gems like this.
|
|
|
|
|
Hm, I'm real puzzled. Whenever I was searching anything in any Enumerable I used foreach. And broke the loop when I did find, what I wanted.
Sample - how you would improve this little thing?
public TreeNode GetNodeByText(TreeNode Parent, string Txt) {
foreach (TreeNode Nd in Parent.Nodes) {
if (Nd.Text == Txt) return Nd;
}
return null;
}
And how do you think is ICollection<T>.Contains() implemented in hundreds of classes?
Steve McConnells Code Complete Loop - Chapter seems not to be available (for free, I mean).
modified on Friday, January 25, 2008 5:28:44 PM
|
|
|
|
|
Well, try not to, but some times you may need to.
Having said that, you may be able to iterate with the index of the nodes.
Or, if you do more searching than adding/removing, you could use a Dictionary<string,TreeNode> to speed up the search.
|
|
|
|
|
So - if somebody else writes bad code you think it's your duty to also write bad code? Just because somebody gives you a foreach doesn't mean that you have to use it in every case. Take a look at the alternatives such as the do/while loop.
Mr.PoorEnglish wrote: Steve McConnells Code Complete Loop - Chapter seems not to be available (for free, I mean).
So do what others do and buy a copy of the book. You won't regret it.
|
|
|
|
|
lol, you are supposed to ignore using break/return completely so you have something to optimize later:
Check out "The Speedup loop"
http://thedailywtf.com/Articles/The-Speedup-Loop.aspx
I could never bring myself to intentionally build a "speedup loop".
|
|
|
|
|
(Please note the joke icon.)
Mr.PoorEnglish wrote: pretty ugly workarounds
Programs are like women:
They can look good but not work.
Or they can work but not look good.
|
|
|
|
|
PIEBALDconsult wrote: Or they can work but not look good.
That's me
|
|
|
|
|
Entirely depends on the cost of DataRowView - it may be a simple reference holder / adapter class whose creation is cheap, and CopyTo likely does only a flat copy (I don't know, though).
An alternative might have to inject very complex code code to provide the same isolation level (e.g. allowing insertions and deletions applied to the underlying dataset during your enumeration).
So this might be a WTF, or might not.
We are a big screwed up dysfunctional psychotic happy family - some more screwed up, others more happy, but everybody's psychotic joint venture definition of CP blog: TDD - the Aha! | Linkify!| FoldWithUs! | sighist
|
|
|
|
|
peterchen wrote: Entirely depends on the cost of DataRowView - it may be a simple reference holder / adapter class whose creation is cheap, and CopyTo likely does only a flat copy (I don't know, though).
Hi peterchen!
I did investigate that and found out, inside of DataView there is an "Index", managing a RBTree, and CopyTo takes the RBTree-Enumerator, who emits Integer - Indicees. These Indicees do reference the target-Datarow in a rowCache-array of the DataTable.
To finally access the DataRowView there is a rowViewCache - Dictionary<DataRow, DataRowView> inside DataView.
I built my own enumerator as wrapper of the RBTreee-Enumerator.
This makes a enumeration-speed-up of DataRow of (only) 1 : 1.5 for 831 DataRows.
To access only the first DataRow (then break foreach) the speed-up-factor is 1 : 4.
So now I'm actually unshure, wether my selfmade-enumerator is worth-while.
|
|
|
|
|
Interesting results - and good you investigated that! So indeed there are reasonable performance tradeoffs.
In any case, I wouldn't expect the enumerator to be optimized for a "break after first". That's a very uncommon scenario - and if you run into it frequently, and it hits your performance, you could always optimize by "get first, test, then enumerate" on the caller side.
We are a big screwed up dysfunctional psychotic happy family - some more screwed up, others more happy, but everybody's psychotic joint venture definition of CP blog: TDD - the Aha! | Linkify!| FoldWithUs! | sighist
|
|
|
|
|
A former place of employment wrote a LOT of engineering software (Fortran naturally).
This was at a time when we were just able to get our hands on a 640kb PC, the software, even with the best compilers and linkers available still sat at over 800kb.
One of the programmers was prone to naming variables using expletives, which made debugging fairly tedious, there's only so many sh#ts and fu$ks you can put up with before it becomes tiring. However what brought the most amusement was a variable for "Volt Drop Analysis" - it was abbreviated to "VDAnal". Nobody could keep a straight face while debugging that section of code, because it was just so unintentional.
|
|
|
|