Why can't I use TEntity?

It seems that the simplest things are hard to understand sometimes ... Many code references are of type TEntity, used for general processing of objects in the entity's data model. I tried to use it in my code and get: "Unknown type" TEntity ", what gives ??? Why do I get" Unknown type "? Is it only available in .net 4.0?

BTW: Using .net 3.5.

I am trying to use the code from this book :

public TEntity ExecuteFirstorDefault<TEntity>(ObjectQuery<TEntity> objectQuery)
  {
    try
    {
      return objectQuery.FirstOrDefault();
    }
    catch (EntitySqlException ex)
    {
      throw ex; //TODO: Replace with handling code
      //additional exceptions as described in Chapter 18
    }
  }
+3
source share
1 answer

TEntityrepresents a generic type type , not a specific type.


I think my question is why I cannot use it, why I can get the Unknown type.

.

, , List<T>. T - , , . , , T, .. :

List<int> myInts = new List<int>();

int. ( ) List, T, int.

+5

All Articles