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
20●16●16●17