Free NHibernate classes as code for domain classes

Ok, so I want to create code for non-aspx classes. I have mapping files (classes) that I want to show in the project as code for entites. Is there any way to do this in VS2008.

+4
source share
3 answers

you can create a designer file by calling it Class.Designer (vb or cs) and it will be displayed as code for any class you create. However, one of the classes must be a partial class.

+1
source

It looks like you're talking about files displayed as attachments in Solution Explorer. ASP.NET Codebehind files are just one example of this.

What you want in the project file looks something like this:

<ItemGroup> <EmbeddedResource Include="Resources.resx"> <Generator>ResXFileCodeGenerator</Generator> <LastGenOutput>Resources.Designer.cs</LastGenOutput> <SubType>Designer</SubType> </EmbeddedResource> </ItemGroup> <ItemGroup> <Compile Include="Resources.Designer.cs"> <DependentUpon>Resources.resx</DependentUpon> <AutoGen>True</AutoGen> <DesignTime>True</DesignTime> </Compile> </ItemGroup> 

I believe that the <DependentUpon> element indicates nesting.

+1
source

I really got it to work. Now the whole "Map" is displayed as the code behind the classes for my objects, it saves a lot of time when searching for Karting for an object. This is how it looks in the project file.

 <Compile Include="Entities\OrderMap.cs"> <DependentUpon>Order.cs</DependentUpon> </Compile> 

We also created a template so that you can simply right-click, select add an NH object and save it in the project, as shown above. Only now the problem is to rename the object, you need to go to the project and manually change the name. But this does not happen often and is a small compromise to increase productivity.

0
source

All Articles