LLBLGen Pro Support System Architecture feed https://www.llblgen.com/tinyforum//Forum/17 This is the RSS feed for the forum Architecture on the LLBLGen Pro Support System forum system. 30 en-us Using own EntityFields inside entities by cerberis <p>We have some legacy code using LLBLGenPro 3.5. Long time ago we introduced custom fields collection :</p> <pre class="nocode">public class CustomEntityFields : EntityFields2, IEntityFields2 </pre><p>It also uses own type of fields: </p> <pre class="nocode">public class CustomEntityField : EntityField2 </pre><p>I have tried to migrate that code to newest version of LLBLGenPro, sadly I ran into issues with these types (maybe there are more, but at the moment the place where I am blocked).</p> <p>Problem for me is that LLBLGen framework expects that fields collection used in entity is created using constructor which accepts StaticEntityFieldsDataContainer staticData, which then sets this._inEntityDataMode = true; There is no other way to set this mode.</p> <p>By default standard fields collection is created inside FieldInfoProvider which is internal and cannot be accessed by user code. I have tried to copy that code in order to set my own IFieldInfoProvider .. But its implementation uses other internal methods of FieldInfo like for example SetIsInMultiTargetEntity.. and so on and so on..</p> <p>Currently with existing 5.x LLBLGen implementation we are not able to migrate our legacy code to newer version because of these issues. One of possibilities of course would be to get rid of those custom collections, but it is so deep in the code that it would be easier to rewrite everything (and then would arise question of ORM... ).</p> <p>So my question then would be: do you have any suggestions how to solve that?</p> cerberis https://www.llblgen.com/tinyforum/Thread/28855#153480 Thu, 28 Mar 2024 09:07:02 GMT Using own EntityFields inside entities https://www.llblgen.com/tinyforum/Thread/28855#153480 Source control strategies for sharing LLBLGen generated code by Walaa <p>For me nuget seems the best option.</p> <p>But in general here are my 2 cents.</p> <p>1- If the LLBLGen generated code is only maintained by one team, and all the rest are just consumers, then a dedicated repo for it only accessible to the team in charge, and the consumers should use nuget to access the appropriate version.</p> <p>2- Otherwise the build script of the consuming projects can reference a dependency on a folder where the DAL artifact is published.</p> <p>3- If all the applications are in the same repo (using different branches), then another branch for the DAL would be good enough.</p> <p>P.S. I don't recommend having any dlls or builds in the source control.</p> Walaa https://www.llblgen.com/tinyforum/Thread/28693#152565 Wed, 29 Mar 2023 17:08:21 GMT Source control strategies for sharing LLBLGen generated code https://www.llblgen.com/tinyforum/Thread/28693#152565 Source control strategies for sharing LLBLGen generated code by jovball <p>I have been using LLBLGen for many years but until now each LLBLGen project has always been part of a single VS solution. I am in a situation now where (ideally) the project or generated code would be used by several different developer teams working on multiple solutions/applications. I am looking for suggestions on the best way to handle this with source control, git in my case.</p> <p>Here are options I have considered so far.</p> <ul> <li> <p>Create a separate repository solution with the LLBLGen project file and the generated code. Create Nuget packages with the generated code. This has some friction in terms of updating the packages on the developer PC and then pushing the nuget packages to the nuget server whenever the application gets pushed to the repo and picked up by the build server.</p> </li> <li> <p>Reference the generated code dlls in a lib folder and include them in the git repo. This would probably involve Git LFS.</p> </li> <li> <p>Use subtrees or submodules. This seems even more complicated in terms of keeping things in sync between the LLBLGen repo and the application repos.</p> </li> </ul> jovball https://www.llblgen.com/tinyforum/Thread/28693#152562 Wed, 29 Mar 2023 01:34:49 GMT Source control strategies for sharing LLBLGen generated code https://www.llblgen.com/tinyforum/Thread/28693#152562 Generics with DTO and Persistence classes by Otis <blockquote><p class="quote-nickname">RamonHenares wrote:</p> <p>Thanks Otis, I will look into that to see if it would fit in with our needs and the way our code is currently implemented.</p> <p>But with that aside, I'm guessing my assumption then is correct that there isn't a way forward with the DTO's?</p> </blockquote> <p>DTOs are projections of entity graphs, and can contain denormalized fields. So they're not first class citizens of the entity model as they're merely a projection of that entity model's elements and are usually used in a readonly fashion (e.g. you return them from a service).</p> <p>Caching entity instances is ok as long as you use them either in a readonly fashion or on the same thread. So the core issue really is: why are you caching entities? If it's to avoid a very slow fetch of data, then the resultset caching might already help a great deal. If it's done because there's an assumption fetching data from the database is 'slow' then it likely isn't needed, as fetching data in our framework is very very fast. </p> <p>But really, for readonly purposes, caching entity instances is fine. I doubt you're caching everything, right? The designer allows you to specify if an entity can be altered (on the mappings tab, 'allowed actions'). You could e.g. create new readonly entities mapped onto the same tables and specify that only 'retrieve' is allowed for these entities, so you can't persist them. You could cache these and use them in readonly logic where you use them in a readonly scenario.</p> Otis https://www.llblgen.com/tinyforum/Thread/28674#152441 Thu, 23 Feb 2023 07:23:29 GMT Generics with DTO and Persistence classes https://www.llblgen.com/tinyforum/Thread/28674#152441 Generics with DTO and Persistence classes by RamonHenares <p>Thanks Otis, I will look into that to see if it would fit in with our needs and the way our code is currently implemented.</p> <p>But with that aside, I'm guessing my assumption then is correct that there isn't a way forward with the DTO's?</p> RamonHenares https://www.llblgen.com/tinyforum/Thread/28674#152440 Wed, 22 Feb 2023 17:31:29 GMT Generics with DTO and Persistence classes https://www.llblgen.com/tinyforum/Thread/28674#152440 Generics with DTO and Persistence classes by Otis <p>Have you looked into resultset caching? <a href="https://www.llblgen.com/Documentation/5.7/LLBLGen%20Pro%20RTF/Using%20the%20generated%20code/gencode_resultsetcaching.htm" rel="nofollow">https://www.llblgen.com/Documentation/5.7/LLBLGen%20Pro%20RTF/Using%20the%20generated%20code/gencode_resultsetcaching.htm</a></p> <p>This will materialize new entity objects around cached resultsets so it won't go to the database if the query is the same. This might remove the need for the caching layer altogether?</p> Otis https://www.llblgen.com/tinyforum/Thread/28674#152439 Wed, 22 Feb 2023 07:41:50 GMT Generics with DTO and Persistence classes https://www.llblgen.com/tinyforum/Thread/28674#152439 Generics with DTO and Persistence classes by RamonHenares <p>Hi,</p> <p>Our LLBLGEN Pro version is 5.7 and we are using the adapter pattern.</p> <p>We are currently using generics in order to create a caching layer in front of the Entity Type. We recently found out that this causes issues due to the fact that the Entity should not be cached, per one of the websites documentations.</p> <p>We were looking to use DTO's instead in order to cache rather than an Entity, but realized that the templates generating DTO's have no base class and that the Persistence classes are DTO object specific.</p> <p>So I wanted to ask, are there any extensions or templates that I need to look at to enable a feature that allows us to use DTO objects as if they were first class citizens of the framework, rather than the Entity? </p> <p>I'm providing a very small set of code here, all from the same class: (I am withdrawing some parts of the code so as to obfuscate our IP, so I hope it comes across well enough)</p> <pre><code class="cs">public class DataCache&lt;TEntity&gt; where TEntity : EntityBase2, IEntity2 </code></pre> <p>Then to get an item from the adapter, we will use one of the Fetch functions, here is an example that has been simplified down:</p> <pre><code class="cs">public TEntity FetchEntityByPK(..) { ... GetFromDB&lt;TEntity&gt;() ... } private static TItem GetFromDB&lt;TItem&gt;(TItem itemIn) { .... adapter.FetchEntity((IEntity2)itemIn); value = itemIn; return value; .... } </code></pre> <p>Since the Persistence classes that are tied to a DTO have a very specific name, e.g. ProjectToJobDto in the case of a Job table, i've hit a dead end with where the code currently is at the moment.</p> <p>Also, my assumption, since the Entity is also being used within the Persistence classes within said ProjectToJobDto, e.g.:</p> <pre><code class="cs">public static ABP.Db.DtoClasses.JobDerivedDto ProjectToJobDerivedDto(this ABP.Db.EntityClasses.JobEntity entity) </code></pre> <p>is that an Entity is a first class citizen and the DTO is a byproduct of wanting a disconnected POCO. </p> <p>So that's where my question lies, is if I can take this further with the hopes that perhaps I have missed something and that there are a set of other libraries or extensions that I do not know about that could help us bridge the gap of replacing the Entity for a DTO by using generics.</p> RamonHenares https://www.llblgen.com/tinyforum/Thread/28674#152438 Tue, 21 Feb 2023 20:57:44 GMT Generics with DTO and Persistence classes https://www.llblgen.com/tinyforum/Thread/28674#152438 Fetching data as object array by alexkor88 <p>Great! thanks for the information <img src="/tinyforum/pics/emojis/simple_smile.png" class="emoji" alt="simple_smile"/></p> alexkor88 https://www.llblgen.com/tinyforum/Thread/27658#151350 Wed, 28 Dec 2022 09:12:23 GMT Fetching data as object array https://www.llblgen.com/tinyforum/Thread/27658#151350 Fetching data as object array by Otis <p>I already did that for you: <a href="https://github.com/FransBouma/RawDataAccessBencher/blob/master/Results/20221124_net6.txt" rel="nofollow">https://github.com/FransBouma/RawDataAccessBencher/blob/master/Results/20221124_net6.txt</a> See repo: <a href="https://github.com/FransBouma/RawDataAccessBencher" rel="nofollow">https://github.com/FransBouma/RawDataAccessBencher</a></p> <p>Please pay attention to the standard deviation value, it sometimes looks like something is slow but there was e.g. 1 or 2 fetches which were slower due to unclear circumstances, e.g. windows decided to do something all of a sudden and a slight delay occurred. You can run it locally btw.</p> <p>The sets fetch 37,000 rows or thereabout (adventureworks, salesorderheader table) so as you can see, performance is pretty ok <img src="/tinyforum/pics/emojis/simple_smile.png" class="emoji" alt="simple_smile"/></p> Otis https://www.llblgen.com/tinyforum/Thread/27658#151349 Wed, 28 Dec 2022 07:40:08 GMT Fetching data as object array https://www.llblgen.com/tinyforum/Thread/27658#151349 Fetching data as object array by alexkor88 <blockquote><p class="quote-nickname">Otis wrote:</p> <p>Use queryspec and the <code>.Select()</code> method (which will create a <code>DynamicQuery</code>, not a <code>DynamicQuery&lt;T&gt;</code> which will return a list of object arrays. No idea why you'd want that tho , but you can using that. <a href="https://www.llblgen.com/Documentation/5.9/LLBLGen%20Pro%20RTF/Using%20the%20generated%20code/QuerySpec/gencode_queryspec_projections.htm#typed-projections" rel="nofollow">https://www.llblgen.com/Documentation/5.9/LLBLGen%20Pro%20RTF/Using%20the%20generated%20code/QuerySpec/gencode_queryspec_projections.htm#typed-projections</a></p> </blockquote> <p>Thanks for your help, It works!</p> <p>Due to some performance concern, we just tried to see if there is a way to fetch data as raw data format, instead of entity format, so we can compare the performance of each methods to fetch data</p> alexkor88 https://www.llblgen.com/tinyforum/Thread/27658#151348 Wed, 28 Dec 2022 07:13:48 GMT Fetching data as object array https://www.llblgen.com/tinyforum/Thread/27658#151348