This is a migrated thread and some comments may be shown as answers.

Need Help with Dynamic Creation of Extents

1 Answer 33 Views
Development (API, general questions)
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
richard
Top achievements
Rank 1
richard asked on 15 Aug 2012, 02:43 PM
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. 
       

1 Answer, 1 is accepted

Sort by
0
Ady
Telerik team
answered on 16 Aug 2012, 10:56 AM
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.

Regards,
Ady
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!
Tags
Development (API, general questions)
Asked by
richard
Top achievements
Rank 1
Answers by
Ady
Telerik team
Share this question
or