In case anybody was wondering, this is the mapping I am now considering:
[Serializable]
[ActiveRecord(Table = "UserProvidedPropertyContainers")]
public class UserProvidedPropertyContainer :
ActiveRecordBase<UserProvidedPropertyContainer> {
IDictionary<string, string> _properties;
public UserProvidedPropertyContainer() { _properties = new
Dictionary<string, string>(); }
[PrimaryKey(PrimaryKeyType.GuidComb)]
public virtual Guid Id { get; set; }
[Property("ContainerName", NotNull = true)]
public virtual string ContainerName { get; set; }
[Property("CreatedDate", NotNull = true)]
public virtual DateTime CreatedDate { get; set; }
[HasMany(typeof(string), "Id", "Properties", Element =
"`Value`", ElementType = typeof(string), Index = "`Key`")]
public virtual IDictionary<string, string> Properties { get {
return _properties; } set { _properties = value; } }
}
and the tables:
create table UserProvidedPropertyContainers (
Id UNIQUEIDENTIFIER not null,
ContainerName NVARCHAR(max) not null,
CreatedDate DATETIME not null,
primary key (Id)
)
create table Properties (
Id UNIQUEIDENTIFIER not null,
[Value] NVARCHAR(max) null,
[Key] NVARCHAR(255) not null,
CONSTRAINT [FK_Properties_UserProvidedPropertyContainers]
FOREIGN KEY([Id])
REFERENCES UserProvidedPropertyContainers (Id),
primary key (Id, [Key])
)
Bill Barry wrote:
> I have the following class that I am using and I was wondering if I
> have a good mapping for it or if I can do better...
>
> [Serializable]
> [ActiveRecord(Table = "UserProvidedPropertyContainers")]
> public class UserProvidedPropertyContainer :
> ActiveRecordBase<UserProvidedPropertyContainer> {
> IDictionary<string, string> _properties;
>
> public UserProvidedPropertyContainer() { _properties = new
> Dictionary<string, string>(); }
>
> [PrimaryKey(PrimaryKeyType.GuidComb)]
> public virtual Guid Id { get; set; }
>
> [Property("ContainerName", NotNull = true)]
> public virtual string ContainerName { get; set; }
>
> [Property("CreatedDate", NotNull = true)]
> public virtual DateTime CreatedDate { get; set; }
>
> [Property("Data", ColumnType = "Serializable", NotNull = true)]
> public virtual IDictionary<string, string> Properties { get {
> return _properties; } set { _properties = value; } }
> }
>
> Actual table: create table UserProvidedPropertyContainers (
> Id UNIQUEIDENTIFIER not null,
> ContainerName NVARCHAR(255) not null,
> CreatedDate DATETIME not null,
> Data IMAGE not null,
> primary key (Id)
> )
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Castle Project Users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/castle-project-users?hl=en
-~----------~----~----~----~------~----~------~--~---