After scrolling through the ServiceStack assembly, I found that the strongly typed client Store()method is actually just SetEntry(key,value)using the utility method to generate the key structure.
IdUtils.CreateUrn , Type Id, , .
CreateKey , , - AceOfBase Key.
public virtual string CreateKey<T>(T entity) where T : AceOfBase
{
return IdUtils.CreateUrn<AceOfBase>(entity.Id);
}
Member m = new Member();
m.Key = CreateKey(m);
, Redis, , , EF.
DomainModels. , .
public class Activity : AceOfBase
{
public AceOfBase IndirectObject { get; set; }
public Participant Predicate { get; set; }
public Participant Subject { get; set; }
public Verb Verb { get; set; }
}
DataModels. DomainModel, , Redis, ( ), .
public class Activity : AceOfBase
{
public string IndirectObject { get; set; }
public string Predicate { get; set; }
public string Subject { get; set; }
public Verb Verb { get; set; }
}
AutoMapper TypeConverter, DataModel DomainModel. AutoMapper , Redis .
Mapper.CreateMap<string,Member>().ConvertUsing<KeyToBaseConverter<Member>>();
Mapper.CreateMap<Member, string>().ConvertUsing<BaseToKeyConverter<Member>>();
public class KeyToBaseConverter<T> : ITypeConverter<string, T> where T : AceOfBase
{
public RedisRepository Repository { get; set; }
public T Convert(ResolutionContext context)
{
return Repository.GetByKey<T>(context.SourceValue.ToString());
}
}
public class BaseToKeyConverter<T> : ITypeConverter<T, string> where T : AceOfBase
{
public string Convert(ResolutionContext context)
{
var f = context.SourceValue as AceOfBase;
return f.Key;
}
}
, , , Lists Sets, , .
, , , JBON blob Key.