LLBLGen Pro Support System Generated code FAQ feed https://www.llblgen.com/tinyforum//Forum/39 This is the RSS feed for the forum Generated code FAQ on the LLBLGen Pro Support System forum system. 30 en-us Can I use the generated code in a Medium Trust environment? by Otis <p>Starting with the LLBLGen Pro runtime framework build of April 4th, 2011, the generated code of v3.0 and v3.1 can be used in a Medium Trust environment. Medium Trust is sometimes required on shared hosting platforms and cloud service providers like GoDaddy or Rackspace. </p> <p>.NET 4 For using the generated code in a Medium Trust environment with .NET 4, the following additional action has to be taken to avoid a security exception related to inheritance:</p> <p>Adapter Add the following line to the AssemblyInfo.cs/vb class in the generated <strong>DbGeneric</strong> VS.NET project:</p> <pre><code class="cs"> // C#: [assembly: System.Security.SecurityRules(System.Security.SecurityRuleSet.Level1)] ' VB.NET: &lt;Assembly: System.Security.SecurityRules(System.Security.SecurityRuleSet.Level1)&gt; </code></pre> <p>SelfServicing Add the following line to the AssemblyInfo.cs/vb class in the generated VS.NET project:</p> <pre><code class="cs"> // C#: [assembly: System.Security.SecurityRules(System.Security.SecurityRuleSet.Level1)] ' VB.NET: &lt;Assembly: System.Security.SecurityRules(System.Security.SecurityRuleSet.Level1)&gt; </code></pre> <p>Linq To use Linq, the service provider has to have enabled ReflectionPermission to be unrestricted. This is in general the case, as Entity Framework and Linq to Sql require this setting to be unrestricted. It's a change in the Medium Trust level, so it's not enabled by default when the default Medium Trust is selected. If your service provider doesn't want to enable ReflectionPermission to be unrestricted, you have to use our native query API instead of Linq. Linq uses compiled lambda's and this .NET 3.5 feature requires ReflectionPermission to be unrestricted.</p> Otis https://www.llblgen.com/tinyforum/Thread/19640#110757 Tue, 05 Apr 2011 09:28:45 GMT Can I use the generated code in a Medium Trust environment? https://www.llblgen.com/tinyforum/Thread/19640#110757 My entity classes don't have a Save() method by MTrinder <p><strong>Alternate Solution</strong></p> <p>You are using the SelfServicing templates but the project you are calling the generated code from does not have a reference to the ORMSupportClasses DLL and has not yet been built. </p> <p>The .Save methods are inherited from base classes in the support dll, and so this needs to be referenced, and the project built, for these to be visible.</p> MTrinder https://www.llblgen.com/tinyforum/Thread/10945#80774 Tue, 14 Oct 2008 19:52:50 GMT My entity classes don't have a Save() method https://www.llblgen.com/tinyforum/Thread/10945#80774 How to generate DTOs with LLBLGen Pro? by Otis <p>For C#, start here: <a href="http://www.llblgen.com/tinyforum/GotoMessage.aspx?MessageID=41429&amp;ThreadID=6261" rel="nofollow">http://www.llblgen.com/tinyforum/GotoMessage.aspx?MessageID=41429&amp;ThreadID=6261</a></p> <p>the same template ported to VB.NET: <a href="http://www.llblgen.com/tinyforum/GotoMessage.aspx?MessageID=65950&amp;ThreadID=11870" rel="nofollow">http://www.llblgen.com/tinyforum/GotoMessage.aspx?MessageID=65950&amp;ThreadID=11870</a></p> Otis https://www.llblgen.com/tinyforum/Thread/11906#66169 Mon, 19 Nov 2007 09:59:55 GMT How to generate DTOs with LLBLGen Pro? https://www.llblgen.com/tinyforum/Thread/11906#66169 Is there a Find method in the Entity collections? by Aglaia <p><strong>Question:</strong> I want to look up an entity in a collection with read entities. Is there a Find method in the Entity collections? </p> <p><strong>Solution:</strong> You can find entities easily with in-memory filtering on an entitycollection. Take for example the following code, which finds the CustomerEntity with the PK &quot;CHOPS&quot; in the customer collection. This works for both Adapter and SelfServicing. It will use the DefaultView object for this.</p> <pre><code class="cs"> // C# CustomerCollection customers = new CustomerCollection(); // get all customers customers.GetMulti(null); IEntityView view = customers.DefaultView; // filter view view.Filter = (CustomerFields.CustomerId == &quot;CHOPS&quot;); // get a reference to the entity to find: CustomerEntity toFind = view[0]; VB.NET Dim customers As New CustomerCollection() ' get all customers customers.GetMulti(Nothing) Dim view As IEntityView = customers.DefaultView ' filter view view.Filter = New FieldCompareValuePredicate(CustomerFields.CustomerId, _ ComparisonOperator.Equals, &quot;CHOPS&quot;) ' get a reference to the entity to find: CustomerEntity toFind = view(0) </code></pre> Aglaia https://www.llblgen.com/tinyforum/Thread/10949#61004 Tue, 21 Aug 2007 11:20:58 GMT Is there a Find method in the Entity collections? https://www.llblgen.com/tinyforum/Thread/10949#61004 Added entity in visual studio.net project isn't there by Aglaia <p><strong>Question:</strong> I've added a new table (also applies to renaming a table and re-adding the entity) and have added the entity to my project after the project refresh. When I generate the code in the directory where my generated code was located and I open the visual studio.net project, the entity is not there! How to solve this?</p> <p><strong>Solution:</strong> Generating code will also create a visual studio.net project file. Since a user can have added own classes to this project file, it will not be overwritten, but updated, if the file is writable. If your visual studio.net project file isn't updated, it's probably read-only, perhaps due to the usage of Visual Sourcesafe. You can check the result of every generation task in the application output window in LLBLGen Pro.</p> Aglaia https://www.llblgen.com/tinyforum/Thread/10948#61003 Tue, 21 Aug 2007 11:20:05 GMT Added entity in visual studio.net project isn't there https://www.llblgen.com/tinyforum/Thread/10948#61003 Using NUnit for testing purposes by Aglaia <p><strong>Question:</strong> I want to unit test the generated code together with my code using NUnit. However it doesn't work, NUnit can't connect to the database, how come?</p> <p><strong>Solution:</strong> If you want to use NUnit for testing purposes, you have to create an app.dll.config file (where app is the name of the project created for NUnit testing) and place it in the bin\debug directory for the NUnit project. For example if you create a new project called &quot;UnitTest&quot; for NUnit testing, and after adding the appropriate references (see LLBLGen Pro and NUnit documentation) you must copy the App.config file that LLBLGen Pro creates to the directory where the NUnit test dll resides (bin\debug) and rename it to &quot;UnitTest.dll.config&quot;.</p> Aglaia https://www.llblgen.com/tinyforum/Thread/10947#61002 Tue, 21 Aug 2007 11:19:34 GMT Using NUnit for testing purposes https://www.llblgen.com/tinyforum/Thread/10947#61002 Is the generated code vulnerable to SQL injection attacks? by Aglaia <p><strong>Question:</strong> LLBLGen Pro generates SQL on the fly and doesn't use stored procedures to do its database operations. Aren't these queries vulnerable for SQL injection attacks? ** Solution:** All SQL generated by LLBLGen Pro is parameterized. This means that no values are embedded into the SQL query being generated. Due to the parameters, a value can never influence the query being executed, as the value will never be part of the query itself, but just a value of a parameter. The generated code is therefore not vulnerable for SQL injection attacks.</p> Aglaia https://www.llblgen.com/tinyforum/Thread/10946#61000 Tue, 21 Aug 2007 11:18:56 GMT Is the generated code vulnerable to SQL injection attacks? https://www.llblgen.com/tinyforum/Thread/10946#61000 My entity classes don't have a Save() method by Aglaia <p><strong>Question:</strong> When I generate code, I noticed that my entity classes don't have a Save() method and my typed list classes don't have a Fill() method. What's wrong?</p> <p><strong>Solution:</strong> You've chosen one of the Adapter generator configurations in the generator configuration screen but you expected SelfServicing code. To get SelfServicing code, select SelfServicing from the Template Group drop-down-list in the General Settings tab of the code generation window.</p> Aglaia https://www.llblgen.com/tinyforum/Thread/10945#60999 Tue, 21 Aug 2007 11:18:24 GMT My entity classes don't have a Save() method https://www.llblgen.com/tinyforum/Thread/10945#60999