Code Generation Template - Active Columns

2 posts, 0 answers
  1. Sambathraj
    Sambathraj avatar
    16 posts
    Member since:
    Jan 2011

    Posted 24 Jan 2014 Link to this post

    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

  2. Jan Blessenohl
    Admin
    Jan Blessenohl avatar
    707 posts

    Posted 27 Jan 2014 Link to this post

    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!
  3. DevCraft banner
Back to Top