That's great.
gnjunge
Posts
-
Generics Casting [modified] -
Generics Casting [modified]For now I made my own work around. The code has changed multiple times, and I'm sure there was a reason for using generics. Have to check it when I have time.
-
Generics Casting [modified]Thanks. Great explanation. I guess I'm not the only one who bumps into this. Any known workarounds? Or rethink the whole implementation from scratch?
-
Generics Casting [modified]Am I missing something, or the example below is really impossible. The class called
FirstImplementation
derives fromGenericClass
, and the generic parameter used,FirstClass
derives fromBase
. So from the outside I should be able to castFirstImplementation
toGenericClass
public class Base { public int X { get; set; } } public class FirstClass : Base { public int Y { get; set; } } public abstract class GenericClass<T> where T: Base { public T Item { get; set;} } public class FirstImplementation : GenericClass<FirstClass> { public GenericClass<Base> Cast() { return (GenericClass<Base> )this; // --> doesn't work } }
modified on Thursday, January 15, 2009 6:18 AM
-
Making shortcuts even shorterCould be, only the project is very new (1 month old) and this function is used on 1 page only (so it was not much work to do a Search & Replace on 1 page).
-
Query QuestionThanks for all the help in brainstorming. The solution works perfect!
-
Making shortcuts even shorterThat's very considerate of you!
-
Query QuestionNot sure if you understood the requirement. In the car case the question/query would be: give me all cars that have at least partid('s) x,y,z (in which x,y,z can be also only one specific part or a number of specific parts). Or in the article/word case: give me all articles that have at least the following words in them.
-
Query QuestionThe app is a matching app. So you could also change car and part to article and word, in which i want to find all articles that have at least some (1 or more) given words. No specific reason again dynamic sql, but always want to know the best way before resorting to dynamic sql which is less maintainable then pure sql.
-
Query QuestionI didn't mean the sum of the part ID's , but the number of parts (that were returned in the query) per car. so if we have the following
carid partid
1 2
1 3
1 4
2 2
2 5
3 2
3 3
3 4
3 5and i would be looking for cars with parts 2, 3, and 4. I would first select all the cars that have at least one of the 3 parts, so cars 1, 2 and 3:
carid partid
1 2
1 3
1 4
2 2
3 2
3 3
3 4Note that car 2 has now only one record, and car 3 only has 3. Then I count how many records per car:
carid count parts
1 3
2 1
3 3I know I was looking for 3 parts, so I select carid 1 and 3. I guess these steps can go into one query.
-
Query QuestionActually just thought of something: select all cars that have at least one of the specific part ids, group on car and it's sum of parts and select only those that have the correct sum of parts. This way no dynamic sql is needed. Didn't try it yet so don't know if this is viable or fast enough.
-
Making shortcuts even shorterI found this in JS:
function toggleDiv(divName)
{
$(divName).toggle();
}So using the shortcut:
toggleDiv('foo');
, we would end up with 17 characters. Using the unusual long version:$('foo').toggle();
, we would end up with 18 characters. -
Query QuestionBut the number of parts can vary. The solution you show is good in case there is a constant number of parts. Is in my case the only solution a dynamic query?
-
Query QuestionThanks, but what happens if I have more than two parts (forgot to add that the number of parts is variable and can range between 1 and up).
-
Query QuestionHi, Suppose I have the following table:
CarID PartID
1 4
1 5
1 7
2 4
2 6
3 5
3 7
4 8Now I want to select each Car that has both parts 5 and 7 (which are cars 1 and 3), what would be the best query? I started with some join, but saw it didn't give the right results. This query should be able to run under heavy stress. Thank you all
-
Duplicate in joinThis seems like it would be very slow, or isn't it? I guess in the end the names table would contain around 10.000 records,whereas the nicknames table would contain around 50.000
-
Duplicate in joinRandom, I don't care which one he returns.
-
Duplicate in joinHi, This must be real simple, but I'm having a blackout. I have two tables: Names:
ID Name
1 John
2 Peter
3 Carl
4 BernardNicknames:
ID NameID NickName
1 1 Bonny
2 1 Bobby
3 1 Jo
4 2 Pete
5 3 Bab
6 3 FooNow I have a search running, which looks for a certain string in both the nickname field as well as in the name field. But it should return only 1 record per name (doesn't matter which nickname), so if the seachstring would be 'b%' it would return the following.
NameID NickNameID Name Nickname
4 null Bernard null
1 1 John Bonny
3 5 Bernard BabI fall on the distinct record thing for the nicknames, I have a dirty subselect, but since the query is actually much bigger, and the table contains 100.000 records, it isn't the right solution. Does anybody have the correct solution to this issue?
-
Composite Collection binding problem [modified]No I didn't. I also stopped momentarily with the project for which I needed it for. So come to making a workaround.
-
Gaia Ajax - recommended yes or noAnybody uses Gaia ajax widgets, http://ajaxwidgets.com/[^]? And what is your experience? Seems like a good alternative for MS asp.net ajax. My reason for not going for MS asp.net Ajax : heavy and confusing client script library, so bad performance, and hard to extend. Thanks, Gidon