Lets imagine model entity:

[HierarchyRoot]
public class User: Entity
{
  [Field]
  public string Name {get;set;]
}

and opposite Dto class:

public class UserDto: IDataErrorInfo
{
  public string _Key {get;set;}
  public string Name {get;set;}

  public string this[string columnName]
  {
     get
     {
        if (columnName == "Name")
        {
           if (string.IsNullOrEmpty(this.Name))
           {
             return "Name cannot be empty!";
           }
        }

        return null;
     }
  }
}

Now creating mapping builder:

var builder = new Xtensive.ObjectMapping.MappingBuilder()
  .MapType<User, UserDto, string>(entity => entity.Key.Format(), objDto => objDto._Key)
  .IgnoreProperty(objDto => objDto.Error)
  .TrackChanges(dto => dto.ID, false);

And when i trying to create Mapper from this mapping description, it fails on:

The primitive property System.String Item [System.String] in UserDto is bound to the property System.Object Item [System.String] in User that isn't primitive.

I can imagine(maybe wrong) why it throws this, because yours Xtensive.Orm.Entity has also indexer with return type object, not like mine string. My question is, how can i tell to mapping description to ignore indexer ? something like IgnoreProperty but for indexer, maybe IgnoreIndexer or something?

Problem is i need such indexer in UserDto class because its implements IDataErrorInfo which is used on app for validation.

asked May 20 '11 at 15:35

Peter%20%C5%A0ulek's gravatar image

Peter Šulek
492313236

edited May 23 '11 at 01:26

Hello Peter,

I'll check this, thanks for the sample.

(May 23 '11 at 06:40) Dmitri Maximov Dmitri%20Maximov's gravatar image

Can you confirm this? I have many Dto classes with indexer and for now i must enclose these parts with #if SILVERILGHT #endif to be not a part of Dto on server side when transform real DO entities to Dto.

(May 24 '11 at 03:07) Peter Šulek Peter%20%C5%A0ulek's gravatar image

One Answer:

Peter, the issue is fixed in 7544 revision. The binaries will be published soon.

answered May 24 '11 at 05:47

Dmitri%20Maximov's gravatar image

Dmitri Maximov
22111211

And how will you fix it?Just ignoring indexer?

(May 24 '11 at 05:58) Peter Šulek Peter%20%C5%A0ulek's gravatar image

Right, properties with indexer are skipped.

(May 24 '11 at 06:53) Dmitri Maximov Dmitri%20Maximov's gravatar image

The nightly build is available in the download section.

(May 24 '11 at 10:58) Dmitri Maximov Dmitri%20Maximov's gravatar image

Downloaded, tested, worked. Confirmed that it was fixed. Thanks a lot!

(May 24 '11 at 15:22) Peter Šulek Peter%20%C5%A0ulek's gravatar image

It was a pleasure =)

(May 25 '11 at 02:58) Dmitri Maximov Dmitri%20Maximov'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:

×574
×23
×6
×1

Asked: May 20 '11 at 15:35

Seen: 4,394 times

Last updated: May 25 '11 at 02:58

powered by OSQA