Basically I'd be looking to implement a method like this.
IQueryAble GetQuery<T>(Entities db) or extension method Entities.GetQuery<T>()
This way you could do things like this
public IQueryable<T> GetAll()
{
return yourEntityClasses.GetQuery<T>();
}
which would return a SELECT * FROM query expression and obviously from there you c...
I've created a web service that uses a generic type Response<TCode, TData> and so I'm ending up with elements like
ResponseOfResponseCodeUserData
ResponseOfResponseCodeArrayOfRightData
etc.
Functionally works just fine but I'm wondering if there's a way to name these particular elements?
EDIT:
Here's an example.
[return: XmlEleme...
I have asked this before but I didn't get the question right so the answer was missed.
If I have a method that returns an ObservableColletion<T> how would I then use this in another generic method.
Would
method2<ObservableCollection<T>>(){}
be the way to go.
I am trying to make a generic resultEventArgs that will pass the results ...
I have a class defined like so:
public class Test {
static <T> List<Class<T>> filter(List<Class<T>> input) {
// code here
}
public static void main(String[] args) {
List<Class<? extends Throwable>> list =
new ArrayList<Class<? extends Throwable>>();
filter(list);
}
}
The filter meth...
Hi,
Just wondering if there is anyway to represent the following code in C# 3.5:
public struct Foo<T> {
public Foo(T item) {
this.Item = item;
}
public T Item { get; set; }
public static explicit operator Foo<U> ( Foo<T> a )
where U : T {
return new Foo<U>((U)a.Item)
}
}
Thanks
...
So I have this general purpose HashTable class I'm developing, and I want to use it generically for any number of incoming types, and I want to also initialize the internal storage array to be an array of LinkedList's (for collision purposes), where each LinkedList is specified ahead of time (for type safety) to be of the type of the gen...
If I have access only keys from a Dictionary<TKey, TValue> what is better to use:
Dictionary<TKey, TValue>.ForEach(pair => action(pair.Key))
or
Dictionary<TKey, TValue>.Keys.ForEach(key => action(key))
Which method is more 'best-practice' ? Speed in both cases I think seems to be very similar.
...
I am working on a WinForms app. There are many instances where I need to display a new screen in the small viewing area, so I am using Panels. Basically, I inherit from panel, expose any properties for the information I need from the panel, anything that needs to happen to display information in the panel happens in it's own code behind....
Currently I have an object implementing the IComparable interface (ASP.NET 3.5, VB). When I place several instantiated objects into a Generics list, I sort them by doing a simple someList.Sort. My CompareTo() function is this:
Public Function CompareTo(ByVal obj As Object) As Integer Implements
System.IComparable.CompareTo
'default is...
I don't understand what is going on here...
I've got the following error:
The type 'TestApp.TestVal' cannot be used as type parameter 'T' in the generic type or method 'TestApp.SomeClass<T>'. There is no boxing conversion from 'TestApp.TestVal' to 'System.IComparable<TestApp.TestVal>'.
This error happens for the following code:
publi...
Hey,
I'm trying to write a method like this:
public static T Test<T>()
{
if (typeof(T)==typeof(string))
return "1241";
// do something else
}
but I can't seem to figure out how to pull it off. I want to return values depending on the type of T that the method was invoked with. I need to return strings, int's, custom classe...
Basically I want to create a method that has a signature like the following:
public <T> T getShellTab(Class<T extends ShellTab> shellTabClass)
but this isn't valid Java.
I want to be able to pass a class that is a subclass of ShellTab and have an instance of that class returned.
public <T> T getShellTab(Class<T> shellTabClass)
wor...
seems simple enough, I want to take a generics list of integers and display them on a datagridview. google comes back with plenty of results on displaying custom classes in a datagridview, but not a list of int. when I just submit the list as the datasource, nothing shows.
I tried using
dim _CheckIns as new list(of integer)
_checkins....
Suppose the following object structure:
class Super {}
class SubA extends Super {}
class SubB extends Super {}
I want to be able to have a variable that will hold the class object for either of my subclasses. I feel like this should do it:
Class<Super> classObj;
Then, I want to be able to something like this:
classObj = SubA.cla...
Naive question about Java syntax. What does
<T> T accept(ObjectVisitorEx<T> visitor);
mean? What would be the C# equivalent?
...
Recently, in company we got some MSSQL database from some old project which we have to integrate in current solution.
Database has about 100-150 stored procedures that use FOR XML AUTO clause, so that queries return complete object-graph as XML instead of rows.
Quickest solution (for us in company) was to create serializable classes (w...
I'm having trouble with inheritance. I can do what I need with single instances of the parent class and child class - as expected the methods of the parent class work fine with instances of the child class.
But, I cannot see how to extend a class that uses an array of the parent class, in a way that allow me to store an array of the ...
I have a method with this signature:
protected final Map<String, Object> buildOutputMappings(
AbstractDataObject ado, MDBase md)
And called with this method (in a subclass):
Map<String, Object> params = buildOutputMappings(ra, md);
I get this compiler warning:
Warning:Warning:line (136)...
Hi,
This is not a question of what is boxing and unboxing,
it is rather why do languages like Java and C# need that ?
I am greatly familiar wtih C++, STL and Boost.
In C++ I could write something like this very easily,
std::vector<double> dummy;
I have some experience with Java, but I was really surprised because I had to write som...
As a followup to this question, first the background
Given a class with this declaration:
public class SomeClass<T>
And a subclass that does not use the generic parameter:
public class SomeSubClass extends SomeClass
A method on SomeClass declared as follows:
protected Map<String, Object> getMap(Object param) {
}
If the subclass...