Would be cool if we could find something to make the mapping fit 'my' needs a bit, but if that is not possible (in IT land everyhing is possible of course) then too bad.
-Mark On Sun, Apr 19, 2009 at 1:26 AM, Paul Batum <[email protected]> wrote: > I'm still pretty weak with using the new conventions functionality, but I > think it should be able to help with the mapping side of things. Perhaps > James can provide some input. > > On Sun, Apr 19, 2009 at 9:18 AM, Mark Nijhof <[email protected]> wrote: >> >> Hi Paul, >> >> In short, I want to try to see if I can extend what I started here: >> >> http://blog.fohjin.com/blog/2009/3/21/FubuMVC_Validation_Convention_based_validation >> which is user input validation to also do domain object (entity) >> validation. After having talked to Jimmy Nilson (he did a local >> presentation) where he said that these rules should live in the >> entities and mentioned that it would be cool if the properties them >> selfs know about the rules and can validate them selfs. So I have an >> idea on how to get this done using Convention over Configuration, I >> only need to know that I can actually map the right things :) >> >> I thought component mapping was for multiple fields, didn't think of >> using it for a single field actually, will try that tomorrow. >> >> Also specifically for my situation (most likely anyway) it would be >> cool if I could do something like this (using the same code): >> >> Map(x => x.EMailAddress); >> Map(x => x.Url); >> >> And have a custom type ValueType<TType> (just like enums I guess) that >> would see that it is a ValueType<TType> and then automatically when. >> >> Map(x => x.EMailAddress); >> >> would underwater do >> >> Component< Person >(x => x.EMailAddress, m => m.Map(x => >> x.EMailAddress.Value, x.EMailAddress.Name)); >> >> Because I would not want to do the repetitive work too much (each >> property in the domain). >> >> What do you think, possible, can it be made easy, I am not neseccarily >> looking for an change in FNH it should probably live with my code, to >> specific for others even if you make it reusable. >> >> -Mark >> >> >> >> On Sun, Apr 19, 2009 at 12:55 AM, Paul Batum <[email protected]> wrote: >> > >> > I'm not sure if I'm quite following what you are trying to do here >> > Mark, but my first question would be whether you are familiar with >> > component mappings? Each of those value types look like they should be >> > mapped as components. >> > >> > On Sun, Apr 19, 2009 at 3:35 AM, Mark Nijhof <[email protected]> >> > wrote: >> >> >> >> Hi, >> >> >> >> Sorry for the title, didn't know how to explain it in one line :) >> >> >> >> Please take a look at the code below: >> >> >> >> public class Person >> >> { >> >> public EMailAddress EMailAddress { get; set; } >> >> public Age Age { get; set; } >> >> } >> >> >> >> public struct EMailAddress : ValueType<string> >> >> { >> >> public string Value { get; set; } >> >> } >> >> >> >> public struct Age : ValueType<int> >> >> { >> >> public string Value { get; set; } >> >> } >> >> >> >> public interface ValueType<TType> >> >> { >> >> TType Value { get; set; } >> >> } >> >> >> >> What I want to do is map the Value property of each ValueType in the >> >> table instead of the actual ValueType. So my table would look the same >> >> as if EMailAddress was a string and Age was an int. There is of course >> >> a little bit more that I want to do except the Value but I kept it >> >> like this for simplicity. >> >> >> >> An other question is that I want NHibernate to create these entities >> >> using a custom factory, but I guess that should go the the NHibernate >> >> list, but would appreciate if someone could already tell me if it is >> >> possible. >> >> >> >> The reason for this is that I want to explore some ideas about >> >> validation. >> >> >> >> -Mark >> >> >> >> > >> >> >> > >> > > >> > >> >> > > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Fluent NHibernate" 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/fluent-nhibernate?hl=en -~----------~----~----~----~------~----~------~--~---
