Passing entities in via constuctor PersistenceSpecification

Maxus's Avatar

Maxus

28 Oct, 2010 11:36 AM via web

Hi People,

Is it possible to do something like this?

        new PersistenceSpecification<Account>(Session)
            .CheckProperty(a => a.Name, account.Name)
            .CheckList(a => a.Users, a => new List<User>
                                                    {
                                                        new User(a) { Login = "test1" },
                                                        new User(a) { Login = "test2" },
                                                        new User(a) { Login = "test3" }
                                                    })
            .VerifyTheMappings();

So the instace can be passed into the construtor of the entity, allowing for read-only properties?

I had a go at trying to create and extension, but had trouble accessing the entity instance to be able to invoke the function. Also I dont 100% understand how the Func<> and expression classes are being used.

Thanks!
Maxus

  1. Support Staff 2 Posted by James Gregory on 05 Nov, 2010 01:51 PM

    James Gregory's Avatar

    I've not seen anyone do that, but that isn't to say you can't!

    Your best bet is to take a look at the source code for our existing methods and see what you can find out from there. The PersistenceSpecification was contributed by another developer, so I'm not intimately aware of how it works, but I can probably answer questions.

  2. 3 Posted by Maxus on 06 Nov, 2010 07:43 AM

    Maxus's Avatar

    Hi James,

    Thanks will take a look.

    Really great work with fluent.

    Cheers,
    Maxus

Reply to this discussion

Preview Comments are parsed with Markdown. Help with syntax

Attached Files

    You can attach files up to 10MB

    What comes next? 'Monday Tuesday Wednesday ?????'