none
Is additional attribute really needed for associations RRS feed

  • Question

  • Hi guys!

    I have two classes: Product and ProductCategory. My XML mapping is as follows:

    <?xml version="1.0" encoding="utf-8" ?>
    <Database Name="spfeatures" xmlns="http://schemas.microsoft.com/linqtosql/mapping/2007">
        <Table Name="product" Member="Product">
            <Type Name="SpFeatures.Core.DomainModel.Product">
                <Column Name="product_id" Member="Id" IsDbGenerated="true" IsPrimaryKey="true" />
                <Column Name="product_name" Member="Name" />
                <Column Name="description" Member="Description" />
                <Column Name="list_description" Member="ListDescription" />
                <Column Name="visible" Member="Visible" />
                <Column Name="url_name" Member="UrlName" />
                <Column Name="list_icon" Member="ListIcon" />
                <Column Name="product_category_id" Member="_categoryId" />
                <Association 
                      Name="Category"
                      Member="Category"
                      ThisKey="_categoryId"
                      OtherKey="Id"
                      IsForeignKey="true" />
            </Type>
        </Table>
        <Table Name="product_category" Member="ProductCategory">
            <Type Name="SpFeatures.Core.DomainModel.ProductCategory">
                <Column Name="product_category_id" Member="Id" IsDbGenerated="true" IsPrimaryKey="true" />
                <Column Name="category_name" Member="Name" />
                <Column Name="description" Member="Description" />
                <Column Name="visible" Member="Visible" />
                <Column Name="url_name" Member="UrlName" />
            </Type>
        </Table>
    </Database>

    My question is: is it somehow possible to avoid using private member I made strong in mapping XML? It seems pretty weird to me if I want to write LinqToSQL library that uses my business classes and to support associations I have to extend all business classes so they have private members for associations. Is it somehow possible to avoid keeping referenced object ID in business class?
    Thursday, June 11, 2009 12:11 AM