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

Code Generation Template - Active Columns

1 Answer 44 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.
Sambathraj
Top achievements
Rank 1
Sambathraj asked on 24 Jan 2014, 05:19 PM

Hi,

Within my database scheme all of the tables are having active columns. I want to modify the code the generation template such that always the Get calls returns me active rows.



I have to do it today like <Entity>.Where(n=>n.Active == true). I would like to avoid repeating such code in the middle tier / UI. Please let me know if there is a way to do this.



Sambath

1 Answer, 1 is accepted

Sort by
0
Jan Blessenohl
Telerik team
answered on 27 Jan 2014, 02:28 PM

Hi Sambath,

My proposal is that you add a partial class to your generated context class and add Active* entry points:



public partial class MyContext

{

    public IQueryable<Entity> ActiveEntities { get { return this.GetAll<Entity>().Where(x=>x.Active == true);}}

}



In your code you can now use context.ActiveEntities.Where().OrderBy()...



Regards,

Jan Blessenohl
Telerik
OpenAccess ORM Q3 2013 simplifies your model operations even further providing you with greater flexibility. Check out the list of new features shipped with our latest release!
Tags
Development (API, general questions)
Asked by
Sambathraj
Top achievements
Rank 1
Answers by
Jan Blessenohl
Telerik team
Share this question
or