I integrated support for "many-to-one" relations ("References(x =>
x.Something)" in FluentNH) in my fork at http://bitbucket.org/forki/functionalnhibernate/
but I'm having a strange problem.
My mapping is:
...
ClassMap<Employee>
[Id <@fun x -> x.Id @>
Field <@fun x -> x.FirstName @>
Field <@fun x -> x.LastName @>]
ClassMap<Store>
[Id <@fun x -> x.Id @>
References <@fun x -> x.HeadOfStaff @> // this is a reference
to employee
HasMany <@fun x -> x.Staff @>]
...
My store is:
let store =
{ Id = 0;
HeadOfStaff = rob;
Staff =
[fred;
steffen;
// rob // adding rob will cause a strange bug?!
]; }
// save store to db
.....
// Get store from db
let store' = sessionFactory.DoInSession (fun session ->
session.Get<Store>(1))
This code works, but if I add rob to store.Staff then I'm getting this
error:
NHibernate.WrongClassException was unhandled by user code
Message=Object with id: 1 was not of the specified subclass:
Examples.FirstProject.Model.Employee (loading object was of wrong
class [Examples.FirstProject.Model.Employee])
Source=NHibernate
EntityName=Examples.FirstProject.Model.Employee
You can try this in the sample project. It seems it has something to
do with the fact that rob is loaded twice.
Regards,
Steffen
Hi Rob,
the saving of the record seems to work (at least no error occurs). I’m getting the error during the loading afterwards.
Regards,
Steffen
Hi,
I have some troubles with lazy loading. I would like to change the sample project to a version where Store.Staff is loaded lazy.
http://bitbucket.org/forki/functionalnhibernate/changeset/f66a37bbdae7/
I changed the mapping to:
<class name="Store" table="[Store]">
…
<bag cascade="all" inverse="true" lazy="true" name="Staff" collection-type="FunctionalNHibernate.FSharpListUserCollectionType`1[[Examples.FirstProject.Model.Employee, Examples.FirstProject, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]], FunctionalNHibernate, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
…
</bag>
…
</class>
But it doesn’t work and I don’t see the problem.
Regards,
Steffen
iif "References" are working we could easily use them and replace all
HasMany-Properties with a extension method like
type Store with
member this.GetStaff session =
Query.create<Staff> session
|> Query.filter <@fun x -> x.Store = this @>
I think then it would be clear that GetStaff is "lazy".
Regards,
Steffen
>> saw from some of your comments you've been using hornget for setting up dependacies.
>> Do you have some scripts for this you can share?
Sorry. I just went to http://www.hornget.net/packages/orm/nhcontrib/nhibernate.linq/nhibernate.linq-2.1 and downloaded the assemblies.
Regards,
Steffen
>>No worries, that's fine, got it building locally with horn now.
Cool,
could please mail me the patch? I’m really interested in adding this as a feature for FAKE.
Best Regards,
Steffen
I'll correct this tonight and probably pull all of Steffen's changes
into my branch.
Cheers,
Rob
On Jan 13, 7:59 am, Robert Pickering <robertfpicker...@gmail.com>
wrote:
> I just used "horn.exe -install:nhibernate.linq -version:2.1", but I indent
> to add this to the fake script along with a second to copy the resulting
> output to the correct tools directories.
>
> Cheers,
> Rob
>
> 2010/1/12 Steffen Forkmann <steffen.forkm...@msu-solutions.de>
>
>
>
> > >>No worries, that's fine, got it building locally with horn now.
>
> > Cool,
>
> > could please mail me the patch? I’m really interested in adding this as a
> > feature for FAKE.
>
> > Best Regards,
>
> > Steffen
>
> > *Von:* functional...@googlegroups.com [mailto:
> > functional...@googlegroups.com] *Im Auftrag **von *Robert Pickering
> > *Gesendet:* Montag, 11. Januar 2010 22:07
> > *An:* functional...@googlegroups.com
> > *Betreff:* Re: Problem with "many-to-one" relation ("References(x =>
> > x.Something)" in FluentNH)
>
> > Cheers,
>
> > Rob
>
> > 2010/1/11 Steffen Forkmann <steffen.forkm...@msu-solutions.de>
>
> > >> saw from some of your comments you've been using hornget for setting up
> > dependacies.
>
> > >> Do you have some scripts for this you can share?
>
> > Sorry. I just went to
> >http://www.hornget.net/packages/orm/nhcontrib/nhibernate.linq/nhibern...downloaded the assemblies.
>
> > Regards,
>
> > Steffen
Many thanks Rob.
thanks to Matthew Podwysocki's excellent blog series about the reader
monad (http://bit.ly/5XbUkV)
I was able to implement Using(), While() and For() functions for the
query monad builder.
You can see the usage (in UnitTests) at
http://bitbucket.org/robertpi/functionalnhibernate/src/3c902cb7d6ca/src/
test/Test.FunctionalNHibernate/QueryMonadTest.fs
These functions allow to compose and chain queries.
Regards,
Steffen
Hi Rob,
my next idea is adding some Reactive Framework features to FNH.
At the moment I have the following code:
// Using For() in query
query {
let! postingGroups = Query.getAll<CustomerPostingGroup>
for postingGroup in postingGroups do
let! balance = postingGroup.GetBalance
printfn "PostingGroup: %s -> Balance %0.2f" postingGroup.Code balance}
|> runQuery
Here I’m getting some “Posting Groups” from the database and calculate for every posting group the balance.
There is no fast way to do the calculation and needs ca. 1s per Posting Group.
This is OK but I want this operation to be non-blocking. So my idea is to convert the query into a IOberservable<T>. Maybe the code could look like this:
let observable =
query {
let! postingGroups = Query.getAll<CustomerPostingGroup>
for postingGroup in postingGroups do
let! balance = postingGroup.GetBalance
yield postingGroup.Code,balance}
|> runQueryAsObservable
Observable.Subscribe (fun (pg,balance) -> printfn "PostingGroup: %s -> Balance %0.2f" pg balance)
What do you think about this?
Should we add the Rx dependency to the FNH main project or should I create a new project?
Best regards,
Steffen
at the moment we have 16 UnitTests in our Test project.
What do you think of changing the TestFramework from plain NUnit to my
NaturalSpec project?
http://bitbucket.org/forki/naturalspec/wiki/Home
Regards,
Steffen
On Jan 26, 6:02 pm, "Steffen Forkmann" <steffen.forkm...@msu-
Cheers,
Rob
On Jan 26, 9:23 am, "Steffen Forkmann" <steffen.forkm...@msu-
Hi,
I converted the tests to NaturalSpec.
Unfortunately the output looks a bit ugly in this case:
Scenario: When running query which returns the session after let bang it should return the session
- Given <fun:op_GreaterGreaterEquals@10>
- When running query
=> It should equal <null>
==> Result is: <null>
==> OK
==> Time: 0.0343s
Regards,
Steffen
my build server shows we have a small build error in FNH at the moment:
[18:28:52]: FSC : error FS0225: Source file
'.\src\app\FunctionalNHibernate\ConnectionStrings.fs' could not be found
[.\src\app\FunctionalNHibernate\FunctionalNHibernate.fsproj]
[18:28:52]: 0 Warning(s)
[18:28:52]: 1 Error(s)
Seems the ConnectionStrings.fs is missing.
Maybe I should add you as a mail recipient of our server. At least until
we can use the teamcity.codebetter.com server.
What do you think?
Best Regards,
Steffen
http://youtrack.jetbrains.net/issue/TW-10866
-----Ursprüngliche Nachricht-----
Von: functional...@googlegroups.com [mailto:functional...@googlegroups.com] Im Auftrag von Steffen Forkmann
Gesendet: Samstag, 30. Januar 2010 18:57
An: functional...@googlegroups.com
Betreff: AW: Build error