Need Help with Dynamic Creation of Extents

Thread is closed for posting
2 posts, 0 answers
  1. richard
    richard avatar
    9 posts
    Member since:
    Jul 2012

    Posted 15 Aug 2012 Link to this post

    I need some help/guidance on how to accomplish the following. 
    Given the name of a db represented in my orm, I need to run a query against it. I would like to get it to the point of running a linq query against it so i could have typing. 
    Also, I would like to use ORM context to take advantage of L2 cache. 
    if (_entitiesModel.Metadata.PersistentTypes.Where(_f => _f.Name == _lookingFor).Any())
    // this gives me an empty object - but i cannot query it
    var _temp = Activator.CreateInstance(AssemblyName, String.Concat(AssemblyName, ".", _filenameWithOutExtension)).Unwrap();
    // this should get me close, but won't compile because of typing
    var _temp2 = Activator.CreateInstance(AssemblyName, String.Concat(AssemblyName, ".", _filenameWithOutExtension)).Unwrap();

    	 _entitiesModel._lookingFor.Where(f => f.IsDeleted == false);
    I am prob. missing something obvious/easy, but any help would be greatly appreciated. 
  2. Ady
    Ady avatar
    589 posts

    Posted 16 Aug 2012 Link to this post

    Hello Richard,

     What do you want to achieve exactly? How are you generating the context ? Have you used the 'Database First' approach to import all tables into the designer and then use the generated context class? Such a context class should have a property that returns IQueryable<T> for each persistent type in your model.
    In case you want to get an extent by specifying the persistent type name, you can add a partial class for the context class and add the following method to it
    public IQueryable GetExtext(string name)
            return GetScope().ExtentByName(name);

    Do send me some more information on what you want to achieve and i would be glad to assist you further.

    the Telerik team
    Follow @OpenAccessORM Twitter channel to be the first one to get the latest updates on new releases, tips and tricks and sneak peeks at our product labs!
Back to Top