Hi,

I couldn't find explanations on persistent interfaces in manual : did I miss it?

I would like to be able to perform queries like :

Query.All<IMyInterface>().Where(e => e.InterfaceField == "value")

IMyInterface would be an interface possibly implemented by different types in different hierarchies.

Regards,


Updated at 23.04.2010 9:58:34

Hi,

This exactly what I need!

However, I found a small bug in latest release:

[HierarchyRoot]
  public class Animal : Entity, IHasName
  {
    [Field, Key]
    public int Id { get; private set; }

    [Field]
    public string Name { get; set; }
  }

  public interface IHasName : IEntity
  {
    [Field]
    string Name { get; set; }
  }

  public class Dog : Animal
  {

  }

This code won't compile:

Erreur  10  PostSharp: Multiple [FieldAttribute] attributes are applied to 'String Animal.Name', but there must be a single one.    d:\code\DoPersistentInterface\DoPersistentInterface\unknown_location    DoPersistentInterface
Erreur  11  PostSharp: Some PostSharp Laos aspects were invalid.    d:\code\DoPersistentInterface\DoPersistentInterface\unknown_location    DoPersistentInterface

So I have to remove the [Field] attribute in class. But in this case I can't implement the interface on subclass only.

If Dog implements the interface, Domain won't build.

[HierarchyRoot]
  public class Animal : Entity
  {
    [Field, Key]
    public int Id { get; private set; }

    [Field]
    public string Name { get; set; }
  }

  public interface IHasName : IEntity
  {
    [Field]
    string Name { get; set; }
  }

  public class Dog : Animal, IHasName
  {

  }

L'exception System.InvalidOperationException n'a pas été gérée
  Message="L'opération n'est pas valide en raison de l'état actuel de l'objet."
  Source="Xtensive.Storage.Model"
  StackTrace:
       à Xtensive.Storage.Model.FieldInfo.CreateMappingInfo()
       à Xtensive.Storage.Model.FieldInfo.UpdateState(Boolean recursive)
       à Xtensive.Storage.Model.NodeCollection`1.UpdateState(Boolean recursive)
       à Xtensive.Storage.Model.FieldInfoCollection.UpdateState(Boolean recursive)
       à Xtensive.Storage.Model.TypeInfo.UpdateState(Boolean recursive)
       à Xtensive.Storage.Model.NodeCollection`1.UpdateState(Boolean recursive)
       à Xtensive.Storage.Model.DomainModel.UpdateState(Boolean recursive)
       à Xtensive.Storage.Building.Builders.ModelBuilder.BuildModel()
       à Xtensive.Storage.Building.Builders.ModelBuilder.Run()
       à Xtensive.Storage.Building.Builders.DomainBuilder.BuildModel()
       à Xtensive.Storage.Building.Builders.DomainBuilder.BuildDomain(DomainConfiguration configuration, DomainBuilderConfiguration builderConfiguration)
       à Xtensive.Storage.Upgrade.UpgradingDomainBuilder.BuildStageDomain(UpgradeStage stage)
       à Xtensive.Storage.Upgrade.UpgradingDomainBuilder.Build(DomainConfiguration configuration)
       à Xtensive.Storage.Domain.Build(DomainConfiguration configuration)
       à DoPersistentInterface.Program.Main(String[] args) dans d:\code\DoPersistentInterface\DoPersistentInterface\Program.cs:ligne 16

Any thought on this?

This thread was imported from our support forum. The original discussion may contain more detailed answer.

asked Apr 22 '10 at 16:08

olorin's gravatar image

olorin
358848792


One Answer:

Hello,

please, check out these posts: http://dmitrimaximov.blogspot.com/2009/ ... art-1.html http://dmitrimaximov.blogspot.com/2009/ ... art-2.html

P.S. The information presented there might be a bit outdated due to possible API changes


Hello,

we'll check this case at the beginning of the next week. It might have happened that this very situation (implementation on subclass only) had not been tested properly.

I've opened the following issue: http://code.google.com/p/dataobjectsdot ... ail?id=637


The issue is fixed, see nightly builds.

For details see the following post: viewtopic.php?f=29&t=5884&p=14560#p14560

answered Apr 22 '10 at 16:24

Dmitri%20Maximov's gravatar image

Dmitri Maximov
22111211

olorin wrote: Thanks I will put it to use.

(Apr 22 '10 at 16:24) Editor Editor's gravatar image
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!
toggle preview

Subscription:

Once you sign in you will be able to subscribe for any updates here

Tags:

×573

Asked: Apr 22 '10 at 16:08

Seen: 2,944 times

Last updated: Apr 22 '10 at 16:08

powered by OSQA