Renaming Domain Method does not appear to affect generated code

4 posts, 0 answers
  1. Richard Fryer
    Richard Fryer avatar
    3 posts
    Member since:
    Feb 2010

    Posted 06 Dec 2011 Link to this post


    I have a question about stored procedure naming through the Stored Procedure Editor vs the name created by the code generator.

    If I have a stored procedure called, let's say, pSYN_GetSynthesisMenu.  I wish to access that stored procedure via the domain method called "dboGetSynthesisMenu".

    I have the following parameters to the Stored Procedure Editor:

    Function Name: dboGetSynthesisMenu
    Stored Procedures: 'pSYN_GetSynthesisMenu'
    Results Sets: ResultSet0(default)

    The Domain Method is listed, as expected, as dboGetSynthesisMenu

    The generated code is:
    public IEnumerable<object> PSYNGetSynthesisMenu(string groupName)
    {
        OAParameter parameterGroupName = new OAParameter();
        parameterGroupName.ParameterName = "groupName";
        parameterGroupName.Value = groupName;
        IEnumerable<object> queryResult = this.ExecuteQuery<object>("'pSYN_GetSynthesisMenu'", CommandType.StoredProcedure, parameterGroupName);
         
        return queryResult;
    }

    I would have expected the generated code to create a public method dboGetSynthesisMenu.  Is this a bug, or am I doing something wrong?

    Thanks

    Rich
  2. PetarP
    Admin
    PetarP avatar
    754 posts

    Posted 07 Dec 2011 Link to this post

    Hello Richard Fryer,

     The name should be changed as per the string you have entered in the function name. If that does not happen then indeed you have found a bug. I have tried it here locally and it seems to work so  I will have to ask you if you have taken any additional steps to reproduce this behavior? For example you might be editing an already existing method (note that this as well works).

    Greetings,
    Petar
    the Telerik team

    Q3’11 of Telerik OpenAccess ORM is available for download. Register for the What's New in Data Tools webinar to see what's new and get a chance to WIN A FREE LICENSE!

  3. DevCraft banner
  4. Richard Fryer
    Richard Fryer avatar
    3 posts
    Member since:
    Feb 2010

    Posted 08 Dec 2011 Link to this post

    Hi Petar

    This is the process I followed:

    1) Create a new Telerik OpenAccess Domain Model SynthesisMenu.rlinq with two tables, tSYN_SynthesisPage and tSYN_SynthesisPageGroup and place in a folder named "Services".
    2) Build the project, succeeds
    3) Right-click new rlinq file and select "Generate OpenAccess Domain Model Service...".  No domain models in the dropdown
    4) Add new Telerik OpenAccess Domain Context called SynthesisModelDomainContext.tt. Name the domain context SynthesisModelDomainContext and select both tables in the list.  New tt file is successfully created and the C# file below is created; apparently all ok.  Build succeeds.
    5) Note domain model still does not show up in the "Select context" dropdown when attempting to "Generate OpenAccess Domain Model Service"
    6) Open the Domain Model and add the stored procedure "pSYN_GetSynthesisMenu" by using "Update from Database".  Stored procedure now appears (called "pSYN_GetSynthesisMenu") in the Model Schema Explorer.  SynthesisModelDomainContext.tt is not updated to reflect the change (should it be?)
    7) Right-click the stored procedure and select Create Domain Method.  Rename the function from pSYN_GetSynthesisMenu to "dboGetSynthesisMenu" and output to persistent type "RIASYnthesisMenu.Web.DashboardPage".  Project builds successfully but tt file still not updated.
    8) Delete and re-add the SynthesisModelDomainContext.tt file.  The Domain Method is present but is called "PSYNGetSynthesisMenu" as in my original post.
    9) Still no option to select the domain model for a domain service
    10) Manually add a Telerik Open Access Domain Service and choose Rlinq file as metadata source type
    11) Rename the domain service as SynthesisMenuDomainService.  Client Access is checked. Select Synthesis.rlinq file from the dropdown (it appears in this view!) , select two tables and enable edit.
    12) The Domain Service files are created but no mention of the stored procedure (either as "PSYNGetSynthesisMenu" or "dboGetSynthesisMenu").

    Please can you help me get this right?

    Many thanks

    Rich



  5. Damyan Bogoev
    Admin
    Damyan Bogoev avatar
    581 posts

    Posted 13 Dec 2011 Link to this post

    Hello Richard Fryer,

    1. I am afraid that this is expected behavior. The OpenAccess Domain Service should generate:
    - Query method named GetEntity(GetCustomers);
    - Method used for CUD operations: InsertEntity, DeleteEntity, UpdateEntity;
    It will not generate the domain methods defined in the model. Additional information about the OpenAccess Domain Service can be found here.
    2. The OpenAccess Domain Context template will be improved in the future. Currently it uses the stored procedure names to generate the corresponding methods instead of the domain methods names. I am sorry for the inconvenience caused.

    Best wishes,
    Damyan Bogoev
    the Telerik team

    Q3’11 of Telerik OpenAccess ORM is available for download. Register for the What's New in Data Tools webinar to see what's new and get a chance to WIN A FREE LICENSE!

Back to Top