Book a Demo

Author Topic: Import C# Classes do not show associations  (Read 6574 times)

jdavid

  • EA User
  • **
  • Posts: 58
  • Karma: +0/-0
    • View Profile
Import C# Classes do not show associations
« on: February 06, 2013, 05:59:22 am »
When I use Import Source Directory, I get all of my classes, but when I start to put the classes on a diagram I would assume that the associations would show up.

Example
Class - SearchResult
Property DataSheets <List> DataSheet

Class - DataSheet

When I place the class SearchResult and DataSheet on a diagram, there is no association....is this normal?

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Import C# Classes do not show associations
« Reply #1 on: February 06, 2013, 08:52:08 am »
There's an option on the C# options page for 'Additional Collection classes'. This is used in reverse engineering to allow associations being created from attributes with an instantiated generic type.

The other thing that I've noticed is that you're describing a 'property'. You'll need to have a physical attribute in addition to the property to get an association created.

jdavid

  • EA User
  • **
  • Posts: 58
  • Karma: +0/-0
    • View Profile
Re: Import C# Classes do not show associations
« Reply #2 on: February 07, 2013, 05:56:02 am »
Here is an example of one of the classes that I import but do not get any association. I would expect that an association would be created between DataSheet (class below) and:

Class: CommonName because of:
public List<CommonName> StrainCommonNames   { get; set; }


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace JaxMiceSearch.Models
{
    public class DataSheet
    {
        public string Id                            { get; set; }
        public string StrainName                    { get; set; }
public List<CommonName> StrainCommonNames   { get; set; }
        public string StockNumber                   { get; set; }
        public string StrainStatus                  { get; set; }
        public string AvailabilityFacet             { get; set; }
        public string StandardSupplyLevel           { get; set; }
        public string MarketingDescription          { get; set; }

        // Strain Information Section
        //public List<StockTypeSection> StockTypes    { get; set; }
        //public List<StrainAppearance> Apperances    { get; set; }
        //public string MatingSystem                  { get; set; }
        //public string BreedingConsiderations        { get; set; }
        //public string Species                       { get; set; }
        //public string BackgroundStrain              { get; set; }
        //public string DonerStrain                   { get; set; }
        //public string Generation                    { get; set; }
        //public string DonatingInvestigator          { get; set; }
        public string GeneralDescription            { get; set; }
        //public string DevelopmentDescription        { get; set; }
        //public string Control                       { get; set; }
        //public List<RelatedStrain> RelatedStrains   { get; set; }
        //public List<Note> AdditionalWebInformation  { get; set; }

        // Phenotype Section


        // Genes & Allele Section
        public List<GeneAllele> GenesAndAlleles     { get; set; }

        // Genotyping Section
        //public List<Note> GenotypingProtocols       { get; set; }
        //public List<Note> HelpfulLinks              { get; set; }

        // Health & Husbandary Section
        //public List<Note> RoomNumber                { get; set; }
        //public string DietInformation               { get; set; }

        // Reference Section
        //public List<Reference> References           { get; set; }

        // Pricing Section
        //public List<PriceListItem> PriceListItems   { get; set; }

        #region ranking and popularity properties

        /// <summary>
        /// Ranking assigned by system administrator
        /// </summary>
        public int Ranking { get; set; }

        /// <summary>
        /// Increments each time the data sheet is selected
        /// </summary>
        public int Popularity { get; set; }

        //public string FoundStrainCommonName { get; set; }

        //public string FoundGeneCommonName { get; set; }

        //public string FoundAlleleCommonName { get; set; }


        #endregion



    }
}
« Last Edit: February 07, 2013, 05:57:31 am by jdavid »

g.makulik

  • EA User
  • **
  • Posts: 355
  • Karma: +0/-0
    • View Profile
Re: Import C# Classes do not show associations
« Reply #3 on: February 07, 2013, 07:12:29 am »
As Simon mentioned you should have physical attributes in your class (not properties with auto-provided fields) to retrieve associations.

HTH
Günther
Using EA9.3, UML2.3, C++, linux, my brain, http://makulik.github.com/sttcl/

jdavid

  • EA User
  • **
  • Posts: 58
  • Karma: +0/-0
    • View Profile
Re: Import C# Classes do not show associations
« Reply #4 on: February 07, 2013, 07:36:20 am »
These are just POCO objects for data transport, these are public properties in C# I don't know what a physical attribute is and I have been using C# for over 10 years.

if I put this in a constructor it still does not show an association
List<CommonName> StrainCommonNames = new List<CommonName>();
« Last Edit: February 07, 2013, 07:40:09 am by jdavid »

g.makulik

  • EA User
  • **
  • Posts: 355
  • Karma: +0/-0
    • View Profile
Re: Import C# Classes do not show associations
« Reply #5 on: February 07, 2013, 08:08:30 am »
A 'physical attribute' means declaring a class member variable that is handled by the get/set implementations explicitly:

Code: [Select]
public class MyClass {
    private int myProperty_;

    public int MyProperty
    {
        get {
            return myProperty_;
        }
        set {
            myProperty_ = value;
        }
    }
}
Using EA9.3, UML2.3, C++, linux, my brain, http://makulik.github.com/sttcl/

jdavid

  • EA User
  • **
  • Posts: 58
  • Karma: +0/-0
    • View Profile
Re: Import C# Classes do not show associations
« Reply #6 on: February 07, 2013, 08:28:22 am »
Just changed the code per your suggestion, rebuilt. And it worked. I sure hope that EA will fix this in the near future since most developers do not use this approach anymore.

Thanks for your help, I thought I was going crazy
« Last Edit: February 07, 2013, 08:39:14 am by jdavid »

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Import C# Classes do not show associations
« Reply #7 on: February 07, 2013, 05:58:59 pm »
If you want Sparx to make changes to EA you have to formally request a change using the Feature Request link you find on the bottom of the page.

I do agree with you, I would expect EA to recognize simple auto-properties like that and treat them the same way as if you would declare the "physical" attribute yourself.

Geert