471,356 Members | 1,714 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,356 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 1957
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Tom Jastrzebski | last post: by
23 posts views Thread by Luc Vaillant | last post: by
4 posts views Thread by Cedric Rogers | last post: by
5 posts views Thread by Wiktor Zychla [C# MVP] | last post: by
3 posts views Thread by LongBow | last post: by
11 posts views Thread by Bryan Kyle | last post: by
10 posts views Thread by Marc Gravell | last post: by
4 posts views Thread by Random | last post: by
4 posts views Thread by =?Utf-8?B?SGF5U2VlZA==?= | last post: by
10 posts views Thread by =?Utf-8?B?QnJpYW4=?= | last post: by
reply views Thread by XIAOLAOHU | last post: by

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.