Question regarding the using directive

Posts   
 
    
JayBee
User
Posts: 282
Joined: 28-Dec-2006
# Posted on: 28-Dec-2006 19:02:50   

Hi,

I'm a new user of LLBLGen. Just generated my first project code. I use the 2classes generator template.

After generation I apply some changes to the classes in EntityClasses. Allmost all the added code is preserved when the project is regenerated. However, some of it is missing.

I added some code to dump data to a diskfile (System.IO.Filestream). To do so I added 'using System.IO' to the list of directives. After regeneration that addition is missing.

Is there a way to prevent this? Or should I use System.IO.Filestream completely. Or should I not add that kind of functionality to business classes? If so, where should I put it then?

Regards,

Jan

jmeckley
User
Posts: 403
Joined: 05-Jul-2006
# Posted on: 28-Dec-2006 19:55:27   

3 options:

  • place code in user defined code regions within the generated file
  • use partial classes to add functionality to the existing object (.net 2.0 only)
  • extend the existing framework to include the new functionality

chances are your "using" statement was not located within a user defined code region.

JayBee
User
Posts: 282
Joined: 28-Dec-2006
# Posted on: 28-Dec-2006 20:19:31   

I was hoping for better alternatives:

Regarding the options you mentioned:

  1. According to me the 'using' directive should be defined outside the namespace it is references in. I do not think it is possible to place it in the user defined code regions.

  2. I prefer using the classes generated by the tool and than adjusting them in such a way that the adjustments are preserved. This is easier to maintain in case of database changes

  3. Since I will not be using the functionality in all situations, it would take something like the conditional addition of CF code to the using group. Perhaps I could do that, but I consider myself a novice in LLBLGen and do not think I have the time to do the research necesary to make such adjustments. It is not something I would prefer to do with product I buy.

If no better solutions come up, I will probably add the code manually everytime the sources are regeneratedcry

jmeckley
User
Posts: 403
Joined: 05-Jul-2006
# Posted on: 28-Dec-2006 20:24:13   

you can add the "using" statement within the namespace. LLBL even has a code region for it! I use this to add the security namespace. Here is a snippet of how I use it:

using SD.LLBLGen.Pro.ORMSupportClasses;

namespace XXX.DAL.EntityClasses
{
    
    // __LLBLGENPRO_USER_CODE_REGION_START AdditionalNamespaces
    using System.Security.Principal;
    // __LLBLGENPRO_USER_CODE_REGION_END

JayBee
User
Posts: 282
Joined: 28-Dec-2006
# Posted on: 28-Dec-2006 20:58:40   

Thnx,

I didn't see that entry before. Thought it was limited to userdefined messages etc.