0

I have a bunch of tables which all have the same column called SessionID of type Guid, this is the ID of the session the entities were created in. I am trying to write a generic class that will count the entities for specific session and specific entity type. Has anyone done something like that with LLBLGen?

public class EntityCounterControl<T> where T : EntityBase2, IEntity2
{       
    public int CountEntities(Guid sessionID)
    {
        //How can I count the entities for type T?

    }
}; 
NeddySpaghetti
  • 13,187
  • 5
  • 32
  • 61
  • do you have entitycollection in-memory? a single collection or multiple collections could have entities for the given sessionID? – Shoaib Shaikh Mar 26 '12 at 05:51
  • 2
    We have a similar case, but doing it with a view that connects all tables with UNION. Think that is more elegant, than doing it with LLBLGen ... You can than query the view and specify the session – BitKFu Mar 26 '12 at 05:53
  • I don't have a collection in memory, also multiple collections/tables can have entities for the same SessionID – NeddySpaghetti Mar 26 '12 at 06:04

1 Answers1

0

Do you really need to use generics? You can create an interface that defines the SessionId property and have your entities implement it.

Andrew Kennan
  • 13,947
  • 3
  • 24
  • 33