Search code examples
codefluent

Most reliable way to find persistence statement or store name in producer


In my model I have a store named MyModel.MyStore. Once the BOM producer run, it becomes a constant whose name is MyModel_MyStoreStoreName

Given a simple producer, I want to add the persistence statement; usually

CodeFluent.Runtime.CodeFluentPersistence persistence = CodeFluentContext.Get(MyModel.Models.Constants.MyModel_MyStoreStoreName).Persistence;

From the entity I've seen I can get the defined store name, but I didn't find any way to have the final store name as constant; i.e. MyModel_MyStoreStoreName;

One way I found is to iterate through methods to filter statement I'm interested in. What is the most reliable way to fetch/build this persistence statement ?

Thanks for your answer,


Solution

  • The Business Object Model Producer (BOM) use the following method to generate the name of the constant:

    CodeFluent.Producers.CodeDom.CodeDomLocal.GetStoreFieldName(entity.Store.Name)