LinqMetaData interface needs a better queryable factory method

Posts   
 
    
worldspawn avatar
worldspawn
User
Posts: 321
Joined: 26-Aug-2006
# Posted on: 05-Jan-2011 02:51:53   

Hello,

ILinqMetaData has this method:

IDataSource GetQueryableForEntity(int typeOfEntity);

Which isn't particularly useful for any abstraction where the entities enum isn't around. What would be much more helpful is a generic factory method, ie:

IDataSource GetQueryableForEntity<TEntity>();

The (generated) implementation of such being something like:

public IDataSource GetQueryableForEntity<TEntity>(){
  return new DataSource2<TEntity>(_adapterToUse, new ElementCreator(), _customFunctionMappings, _contextToUse);
}

Currently I always seem to need the generated strong typed LinqMetaData class to create an IQueryable... unless there is another way?

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 05-Jan-2011 03:22:26   

worldspawn wrote:

Currently I always seem to need the generated strong typed LinqMetaData class to create an IQueryable... unless there is another way?

Could you please explain a little bit more why this implementation affects you? (show us some code snippet).

David Elizondo | LLBLGen Support Team
MarcoP avatar
MarcoP
User
Posts: 270
Joined: 29-Sep-2004
# Posted on: 08-Jan-2011 19:42:40   

worldspawn wrote:

Hello,

ILinqMetaData has this method:

IDataSource GetQueryableForEntity(int typeOfEntity);

Which isn't particularly useful for any abstraction where the entities enum isn't around. What would be much more helpful is a generic factory method, ie:

IDataSource GetQueryableForEntity<TEntity>();

The (generated) implementation of such being something like:

public IDataSource GetQueryableForEntity<TEntity>(){
  return new DataSource2<TEntity>(_adapterToUse, new ElementCreator(), _customFunctionMappings, _contextToUse);
}

Currently I always seem to need the generated strong typed LinqMetaData class to create an IQueryable... unless there is another way?

I just added an extension method:


    public static class LinqMetaDataExtensions
    {
        public static IQueryable<TEntity> CreateQueryable<TEntity>(this LinqMetaData metaData) where TEntity : class 
        {
            return new DataSource2<TEntity>(metaData.AdapterToUse, new ElementCreator(), metaData.CustomFunctionMappings, metaData.ContextToUse);
        }
    }

MarcoP avatar
MarcoP
User
Posts: 270
Joined: 29-Sep-2004
# Posted on: 10-Jan-2011 19:06:23   

However, I would agree I would love to see the IDataSource GetQueryableForEntity<TEntity>() generic form added to the ILinqMetaData interface for abstraction purposes.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 11-Jan-2011 12:34:53   

We'll look at this for a future v3.x version.

Frans Bouma | Lead developer LLBLGen Pro
TomDog
User
Posts: 618
Joined: 25-Oct-2005
# Posted on: 13-Jan-2011 02:16:23   

Otis wrote:

We'll look at this for a future v3.x version.

That would be nice! BTW There are similar methods in this class EntityHelper.cs

Jeremy Thomas