EntitiesModel Access Modifier

2 posts, 0 answers
  1. Dan
    Dan avatar
    1 posts
    Member since:
    Mar 2015

    Posted 25 Mar 2015 Link to this post

    Is there any way to change the access modifier of the generated EntitiesModel?  I'm trying to create a n-Tier architecture which means that the only thing I want exposed out of my Repository layer is the interfaced classes that I create.  I want the EntitiesModel and all subsequent generated code to remain internal to the assembly.  I have set all the generated domain classes to Assembly and they are tagged with the "internal" access modifier, but the code is still exposing EntitiesModel and IEntitiesModelUnitOfWork.  Any way to also sent those to assembly/internal?

  2. Doroteya
    Doroteya avatar
    497 posts

    Posted 30 Mar 2015 Link to this post

    Hi Dan,

    Thank you for your interest in Telerik Data Access.

    In general, it is possible to achieve the needed restriction by a modification of the code generation templates, but the complete scenario will not work. Currently, the runtime of Data Access does not support interface abstraction.

    If you are interested in the code generation modification steps anyway, here they are:
    1. Copy the Data Access code generation templates in your project as described in the Copy the Templates Locally section of this documentation article. Note that the article is for another scenario. It is important to execute only the steps in the Copy the Templates Locally section.
    2. Open the ContextGenerator.ttinclude template and replace the code on line 53 with the following:
    internal partial class <#= contextClass.Name #> : <#= contextClass.BaseClass.Name #>, <#= contextClass.IUnitOfWorkInterface.Name #>
    3. Open the InterfacesGenerator.ttinclude template and replace the entire GenerateInterfaceSignature() method with the following:
        protected void GenerateInterfaceSignature(Telerik.OpenAccess.CodeGeneration.CodeInterface codeInterface)
            string implementsStr = string.Empty;
                implementsStr = " : " + string.Join(", ", codeInterface.Implements.Select(i => i.Name).ToArray());
    internal interface <#= codeInterface.Name #><#= implementsStr #>
    <#= codeInterface.TypeAccessModifier.ToCode() #> interface <#= codeInterface.Name #><#= implementsStr #>
    4. Save the two templates.
    5. Open the .rlinq file in Visual Designer, move a class on the diagram and save the .rlinq file.

    At this point, the context class and the interface should be internal.

    I am sorry for the inconvenience caused. Do let us know, if you need further information.

    OpenAccess ORM is now Telerik Data Access. For more information on the new names, please, check out the Telerik Product Map.
  3. DevCraft banner
Back to Top