Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6056345
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T08:21:58+00:00 2026-05-23T08:21:58+00:00

A question about using interfaces on presentationModels with RIA services . It is possible

  • 0

A question about using interfaces on presentationModels with RIA services.

It is possible to expose a object via Ria Services that implements an interface?

The interface:

public interface TestInterface
{
    public int ID {get;set;}
}

We have a presentationModel :

public class TestPresentationModel : TestInterface
{
   [Key]
   public int ID {get;set;}
}

I now get a compilation error:
The entity ‘TestInterface’ in DomainService ‘SomeDomainService’ does not have a key defined. Entities exposed by DomainService operations must have at least one public property marked with the KeyAttribute.

I tried to add a [Key] attribute, but then I get following error:
The derived entity type ‘TestPresentationModel’ must be declared in a KnownTypeAttribute on the root entity ‘TestInterface’.

I tried to add the [KnownTypeAttribute] attribute, but then I get following compilation error:
Attribute ‘KnownType’ is not valid on this declaration type. It is only valid on ‘class, struct’ declarations.

It seems that Ria services tries to treat the interface as an entity? How can we overcome this problem?

Regards,

Stephane

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T08:21:58+00:00Added an answer on May 23, 2026 at 8:21 am

    It´s possible to use an interface for a class (viewModel) that you need on server and on client side. To to that you need to share the interface and the partial viewmodel class with the interface implementation.

    In your case you need to define the classes and files as following in the server project:

    File: ITestInterface.shared.cs

    public interface TestInterface{
      public int ID {get;set;}
    }
    

    File: TestPresentationModel.cs

    public partial class TestPresentationModel {
      [Key]
      public int ID {get;set;}
    }
    

    File: TestPresentationModel.ITestInterface.shared.cs

    public partial class TestPresentationModel : ITestInterface {
       // can be empty cause the interface implementation is in TestPresentation.cs
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a question about using new[] . Imagine this: Object.SomeProperty = new[] {string1,
This question is about using getter methods of a singleton object in worker threads.
I have a question about using streams in .NET to load files from disk.
I have a question about using os.execvp in Python. I have the following bit
A recent question came up about using String.Format(). Part of my answer included a
This recent question about sorting randomly using C# got me thinking about the way
Just got a question about generics, why doesn't this compile when using a generic
I've got a pretty basic question about how to start using Castle Windsor. I've
In this question , I asked about using queue's and threads in C#. I
From this question , a neat answer about using COALESCE to simplify complex logic

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.