This is a migrated thread and some comments may be shown as answers.

[Solved] Interface in visual designer: class is not associated with a column

6 Answers 183 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
arjen
Top achievements
Rank 1
arjen asked on 15 Nov 2010, 08:23 PM
By implamenting an interface in visual designer, I get the message 'The member with name 'MyField' of the 'MyClass' persistent class is not associated with a column'.
Double click on the warning shows the 'Resolve Validation Errors' form.
Selecting 'Map a column to this field' shows a User input column combobox.
This combobox is empty. I'm not able to select a column.

6 Answers, 1 is accepted

Sort by
0
Zoran
Telerik team
answered on 17 Nov 2010, 12:23 PM
Hi arjen,

 It seems that all of the columns of your table which is mapped to the class that implements the interface are already mapped to persistent fields. However this warning should not bother you too much as you can just run the Update Schema From Model wizard and OpenAccess will create a column for the members that you have implemented from your interface. 

Best wishes,
Zoran
the Telerik team
See What's New in Telerik OpenAccess ORM in Q3 2010!
Monday, November 15, 11 am Eastern Time: Register here>>
Monday, November 15, 10 pm Eastern Time: Register here>>
0
arjen
Top achievements
Rank 1
answered on 17 Nov 2010, 01:47 PM
Hi Zoran,

I keep struggling with interfaces.
Is there an example somewhere?
I assume that Interfaces works the same way in c# as in Delphi.

I want to use an interface without new columns in the database.
This:
    public abstract partial class MetaClass1 : Interface1
    {
        private int iD;
        public virtual int ID 
        
            get
            {
                return this.iD;
            }
            set
            {
                this.iD = value;
            }
        }
}

And not this:
public abstract partial class MetaClass1 : Interface1
{
    private int iD;
    public virtual int ID 
    
        get
        {
            return this.iD;
        }
        set
        {
            this.iD = value;
        }
    }
      
    private int interface1ID;
    public virtual int Interface1.ID 
    
        get
        {
            return this.interface1ID;
        }
        set
        {
            this.interface1ID = value;
        }
    }
      
}

But how to implement an Interface in the visual designer?
I use at the moment an Inheritance relationship between MetaClass1 and Interface1.
0
Zoran
Telerik team
answered on 22 Nov 2010, 10:45 AM
Hello arjen,

 You are definitely using the correct approach with interfaces in the Visual Designer, the inheritance relationship is the one that is intended to be used. I must admit I am not sure what is the desired result that you expect though from the example you have given in your last post. Are you intending to have an ID property only coming from your interface or would you like to have an ID property which is a property of your class and then the interface left to be implemented by yourself separately. If you have a property from your interface that has the same name as a property in your implementing class, then the result that you are getting is the expected one - the property is generated once as the member of the class and once as an explicit implementation of the interface. If you would like to have only one of the properties there you should just delete/rename one of the ID properties - either on the interface or the MetaClass. 
If your intention is to implement the interface on your own and not having OpenAccess generating the implementation code - this is not something that we provide at the moment but we will definitely have it on our TODO list for the future. We are looking forward for your feedback, any suggestions will be highly appreciated.

Regards,
Zoran
the Telerik team
Accelerate your learning with industry's first Telerik OpenAccess ORM SDK. Download today.
0
arjen
Top achievements
Rank 1
answered on 22 Nov 2010, 05:37 PM
Hi Zoran,

I want to use an Interface on a couple of tables wich are used by Combobox/Dropdown/Autocomplete.
An interface with ID and Description.

public interface Interface1
{
    int ID { get; set; }
    string Description { get; set; }
}
public partial class MetaClass1 : Interface1
{
    private int iD;
    public virtual int ID 
    
        get
        {
            return this.iD;
        }
        set
        {
            this.iD = value;
        }
    }
      
    private string description;
    public virtual string Description 
    
        get
        {
            return this.description;
        }
        set
        {
            this.description = value;
        }
    }   
}

Adding a MetaClass, an Interface and an Inheritance between them adds the 2 Interface MetaProperties to the implementations section of the MetaClass.

This results in 4 properties in the MetaClass1.generated.cs file.
Removing the 2 MetaProperties from the implementations section gives an error (after saving):

Errors were generated when initializing the transformation object. The transformation will not be run.  The following Exception was thrown:
System.ArgumentNullException: Value cannot be null.
Parameter name: language
   at Telerik.OpenAccess.Metadata.Utils.GetDomProvider(String language)
   at Telerik.OpenAccess.Metadata.DefaultNamingStrategy.ValidateGeneratedName(String suggestion, MetaScopeType declaringType)
   at Telerik.OpenAccess.Metadata.DefaultNamingStrategy.GetScalarFieldName(String propertyName, String userFieldName, MetaScopeType declaringType)
   at Telerik.OpenAccess.InheritanceWorker.ImplementMemberFromInterface(String name, Type clrType, MetaInterface metaInterface, IList`1 targetClasses, MetadataWorker worker)
   at Telerik.Data.Dsl.ImplementationAddRule.<>c__DisplayClass6.<ElementAdded>b__4()
   at Telerik.Data.Dsl.DslBridge.RedoAction(ActionState state)
   at Telerik.Data.Dsl.StateManager`1.AddNewState(T state)
   at Telerik.Data.Dsl.ImplementationAddRule.ElementAdded(ElementAddedEventArgs e)
   at Microsoft.VisualStudio.Modeling.AddRuleNotification.DoFireRule()
   at Microsoft.VisualStudio.Modeling.RuleNotification.FireRule()
   at Microsoft.VisualStudio.Modeling.Transaction.FireCommitTimeRules(SortedRuleNotificationList rulesToFire)
   at Microsoft.VisualStudio.Modeling.Transaction.FireCommitTimeElementRules()
   at Microsoft.VisualStudio.Modeling.Transaction.Commit()
   at Microsoft.VisualStudio.TextTemplating56565F5FCA10B107CB7AE998027F6F64.GeneratedTextTransformation.Initialize() in d:\users\arjen\Mijn documenten\Visual Studio 2010\Projects\ConsoleApplication3\ConsoleApplication3\EntityDiagrams1.rlinq:line 41
   at Microsoft.VisualStudio.TextTemplating.TransformationRunner.RunTransformation(TemplateProcessingSession session, String source, ITextTemplatingEngineHost host, String& result)  1 1 

I got the feeling that would be the right approaches.


Regards,
Arjen
0
Accepted
Zoran
Telerik team
answered on 24 Nov 2010, 10:29 AM
Hello arjen,

 Well actually, if the properties of the interface and the ones of the MetaClass overlap each other, you should delete the ones of the MetaClass so that the class actually uses that ones that it implements from the interface. If a class implements an interface, it is not a good idea to delete the implemented properties that the class inherits from the interface.

Best wishes,
Zoran
the Telerik team
Accelerate your learning with industry's first Telerik OpenAccess ORM SDK. Download today.
0
arjen
Top achievements
Rank 1
answered on 24 Nov 2010, 11:18 AM
Thanks for your patience Zoran,

Thats what I'm looking for.
Tags
General Discussions
Asked by
arjen
Top achievements
Rank 1
Answers by
Zoran
Telerik team
arjen
Top achievements
Rank 1
Share this question
or