473,405 Members | 2,300 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Generics, Type and typeof()

hi @all,

I have the following interface declaration:

public interface IBaseDao<Twhere T : BasePOJO
{
List<TFindAll(Type entityClass);
}

The parameter entityClass should be typeof(T).

I thought of something like

List<TFindAll(Type<TentityClass);

but there is not such a generic for Type.

So, is this possible?
mfG
--stefan <--
Sep 11 '08 #1
3 2044
Can you clarify what it is you want to do? I can interpret that a few
different ways...

Perhaps if you indicate how you want to call it and what you want to happen?

Marc
Sep 11 '08 #2
I agree with the first commenter that it's hard to understand what
you're trying to do.

Given what you've said, one possible interpretation says maybe this
would be what you're looking for:

public interface IBaseDao<Twhere T : BasePOJO
{
List<TFindAll(T entityClass);
}

Is that it, or do we just need more information?

Kyle

On Sep 11, 8:05*am, Stefan Hoffmann <stefan.hoffm...@explido.de>
wrote:
hi @all,

I have the following interface declaration:

* * *public interface IBaseDao<Twhere T : BasePOJO
* * *{
* * * * *List<TFindAll(Type entityClass);
* * *}

The parameter entityClass should be typeof(T).

I thought of something like

* * *List<TFindAll(Type<TentityClass);

but there is not such a generic for Type.

So, is this possible?

mfG
--stefan <--
Sep 11 '08 #3
hi Marc, Kyle,

I should have give you my actual case:

I'm trying to convert an interface from Jave to C#. In Jave it looks
like this:

public interface IBaseDAO<T extends BasePOJO>
{
List<TfindAll(Class<TentityClass);
}

I found an Java guy, who explained it: it's basically a hack, as the
implementation looks like:

public List<TfindAll(Class<TentityClass)
{
List<Tresults = getHibernateTemplate().loadAll(entityClass);
return results;
}

It seems that they can't use

public List<TfindAll()
{
return GetHibernateTemplate().LoadAll(typeof(T));
}

as we can do in C#.

Thanks for your efforts.
mfG
--stefan <--
Sep 11 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Tom Jastrzebski | last post by:
Hello everybody, Here is the problem I came across experimenting with Generics. I would like to write a class or a struct adding integer to any other, initially undefined *numeric type*. So, my...
23
by: Luc Vaillant | last post by:
I need to initialise a typed parameter depending of its type in a generic class. I have tried to use the C++ template form as follow, but it doesn't work. It seems to be a limitation of generics...
4
by: Cedric Rogers | last post by:
I wasn't sure if I could do this. I believe I am stretching the capability of what generics can do for me but here goes. I have a generic delegate defined as public delegate bool...
5
by: Wiktor Zychla [C# MVP] | last post by:
suppose I have a class class MyContainter { List<something1list1; List<something2list2; ... List<somethingnlistn; othertype1 otherfield1; ...
3
by: LongBow | last post by:
Hello all, First of all, sorry for multiple question per one thread. I have two questions. First what I think might be the easier problem. I am capturing data from an embedded device which I...
11
by: Bryan Kyle | last post by:
Hi All, I'm fairly new to C# and Generics and I'm wondering if anyone has some suggestions for me. I'm trying to implement a simple DAO framework using generics to keep my code as clean as I...
10
by: Marc Gravell | last post by:
Given a generic method "of T", is there a good way of ensuring that any static ctor on T has executed? Following code demonstrates (TestClass1) that via generics you can use the Type instance long...
4
by: Random | last post by:
I want to define a generics method so the user can determine what type they expect returned from the method. By examining the generics argument, I would determine the operation that needs to be...
4
by: =?Utf-8?B?SGF5U2VlZA==?= | last post by:
Is there some way to use Generics in dynamic code using the Type.GetType("MyClassName") as an argument? List<Type.GetType("MyClassName") oList = new List<Type.GetType("MyClassName") > ...
10
by: =?Utf-8?B?QnJpYW4=?= | last post by:
What is the easiest way to convert primitives to a byte array? I tried the BinaryFormatter serialization but it serializes objects so when I serialized an and int it took 54 bytes instead of 4. I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.