Hi,

I am getting the following query error on localization fields.

  public Person GetPersonByTitle(string Title)
    {

       System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US");

        return (from p in Session.Query.All<Person>()
                     where p.Title == Title
                     select p).FirstOrDefault();

System.Globalization.CultureInfo en = new System.Globalization.CultureInfo("en-US");

Error:{"Field 'p.Title' must be persistent (marked by [Field] attribute)."}

With this other method I get a different error:

return (from p in Session.Query.All<Person>()
                     where p.Localizations[en].Title == Title
                     select p).FirstOrDefault();

Error: 'Xtensive.Orm.Localization.LocalizationSet <datamodel.baseentitylocalization>.get_Item' is not supported"}

Data Model:

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

    [Field(Length = 100)]
    public string Name { get; set; }

    [Field]
    public bool Active { get; set; }

    [Field]
    public DateTime DateAdded { get; set; }

    [Field]
    public DateTime DateModified { get; set; }

    [Field] // This is a storage of all localizations for Person class
    public LocalizationSet<BaseEntityLocalization> Localizations { get; private set; }

    // Localizable field. Note that it is non-persistent
    public string Title
    {
        get { return Localizations.Current.Title; }
        set { Localizations.Current.Title = value; }
    }
}

[HierarchyRoot]
public class BaseEntityLocalization : Localization<BaseEntity>
{
    [Field(Length = 100)]
    public string Title { get; set; }

    public BaseEntityLocalization(Session session, CultureInfo culture, BaseEntity target)
        : base(session, culture, target) { }
}

public class Person : BaseEntity
{

    [Field(Length = 100)]
    public string FirstName { get; set; }

    [Field(Length = 100)]
    public string LastName { get; set; }

    [Field]
    public DateTime DateOfBirth { get; set; }

    public string FullName 
    {
      get {  return FirstName + LastName ;}

      private set { }

    }
}

Thank you,

Richard

asked Aug 05 '13 at 15:24

rasxte's gravatar image

rasxte
20161617

edited Aug 05 '13 at 21:00

Dmitri%20Maximov's gravatar image

Dmitri Maximov
22111211


2 Answers:

Dmitri,

You are right... Sorry I missed that.

Thank you,

Richard

answered Aug 06 '13 at 12:23

rasxte's gravatar image

rasxte
20161617

Hi Richard,

I bet you forgot implementing ILocalizable<BaseEntityLocalization> on BaseEntity type. See Localization manual, #3.

answered Aug 05 '13 at 21:04

Dmitri%20Maximov's gravatar image

Dmitri Maximov
22111211

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:

×18
×2
×1

Asked: Aug 05 '13 at 15:24

Seen: 14,462 times

Last updated: Aug 06 '13 at 12:23

powered by OSQA