Say, is there a way to specify this:

Blog : Posts

 

Load a blog by id, but leave posts empty. On save don't save posts.

 

But, if there is explicit call, lets say blog.LoadPosts(), then posts would be 
loaded and therefore a relation would be »normal«.

 

The reason is that I found that there are so many sqls executing – it is 
logical, because objects are in relation, but i would like to be more in 
control (n-tier situation). Lazy is not good for n-tier situations.

 

Right now I have this configured like this.

Blog has a array of posts(POSTS), but it is NOT attributesied as HasMany.

Post has a BLOG property, but it is also NOT attibutiesed as BelongsTo

 

When I need to send those to client, i manually fill necessary details.

 

But is there a way to run-time attributise an element, say array of posts in a 
blog, and then load it using this run-time attributisation?

 

Hope you understand this.

 

Br,ivan

 

From: [email protected] 
[mailto:[email protected]] On Behalf Of Markus Zywitza
Sent: Wednesday, October 20, 2010 9:29 PM
To: [email protected]
Subject: Re: two questions

 

It is not N+1, it is 2.

Assume you have Blog : Posts as 1 : n with a non-lazy posts collection.
If you load a blog, there are 2 queries - one for the blog and one for all 
posts.

N+1 occurs when you have 1 : n with a lazy collection and you are enumerating 
the collection. Then you have one query for the blog and n queries for n posts.

As a result, if your collection is not lazy, there is no N + 1. So the 
Eager=true flag would be only useful if you had a lazy collection, nullifying 
the laziness because of eager loading.

Eager loading is useful in the case you have a lazy collection but you know 
that you need to load all the referenced entities. Then you can specify in a 
query, that in this situation there should be no lazy loading, but getting all 
the childs at once.

-Markus

2010/10/20 Ivan Bolčina <[email protected]>

Sorry, I ment why is there not a simple way to do 1 query instead of N+1?

 

 

 

From: [email protected] 
[mailto:[email protected]] On Behalf Of Markus Zywitza
Sent: Wednesday, October 20, 2010 4:50 PM


To: [email protected]
Subject: Re: two questions

 

Because that's the default behaviour. If you do not specify lazyness, all 
entities referenced from a loaded entity are loaded directly after it. Lazyness 
is used to stop NH/AR from loading objects that are not needed.

 

-Markus

2010/10/20 Ivan Bolčina <[email protected]>

Hi.

 

Why isnt there a flag in relation like lazy but for eager loading?

 

From: [email protected] 
[mailto:[email protected]] On Behalf Of Roelof Blom
Sent: Tuesday, October 19, 2010 9:07 AM 


To: [email protected]
Subject: Re: two questions

 

http://stw.castleproject.org/Active%20Record.Tuning%20(performance%20improvements).ashx
 
<http://stw.castleproject.org/Active%20Record.Tuning%20%28performance%20improvements%29.ashx>
 

On Tue, Oct 19, 2010 at 8:21 AM, Ivan Bolčina <[email protected]> wrote:

Wow, nice... How come I didn't find anything in documentation.

 

Also, is there fetch join in active record?

 

From: [email protected] 
[mailto:[email protected]] On Behalf Of Roelof Blom
Sent: Monday, October 18, 2010 12:52 PM
To: [email protected]
Subject: Re: two questions

 

Inline

On Mon, Oct 18, 2010 at 9:59 AM, Ivan Bolčina <[email protected]> wrote:

Hi.

 

Two questions:

1.       Is there a LINQ to Caste active record?

Yes, use the extension methods in 
Castle.ActiveRecord.Framework.ActiveRecordLinq,

or derive from ActiveRecordLinqBase<T>

2.       What is the best way to write simple queries like »...where name like 
'%john%' and age>10«

use the PredicateBuilder  
<http://www.albahari.com/nutshell/predicatebuilder.aspx> class on the 
IQueryable supplied by ActiveRecord

 

Thanks

 

Ivan Bolčina
SOFTWARE DEVELOPMENT
MANAGER

 <mailto:[email protected]> [email protected]

tel: +386 51 680 415

 



 <http://www.apida.si/> www.apida.si

 

 

-- 
You received this message because you are subscribed to the Google Groups 
"Castle Project Development List" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected] 
<mailto:castle-project-devel%[email protected]> .
For more options, visit this group at 
http://groups.google.com/group/castle-project-devel?hl=en.

 

-- 
You received this message because you are subscribed to the Google Groups 
"Castle Project Development List" 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-devel?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"Castle Project Development List" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected] 
<mailto:castle-project-devel%[email protected]> .
For more options, visit this group at 
http://groups.google.com/group/castle-project-devel?hl=en.

 

-- 
You received this message because you are subscribed to the Google Groups 
"Castle Project Development List" 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-devel?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"Castle Project Development List" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected] 
<mailto:castle-project-devel%[email protected]> .
For more options, visit this group at 
http://groups.google.com/group/castle-project-devel?hl=en.

 

-- 
You received this message because you are subscribed to the Google Groups 
"Castle Project Development List" 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-devel?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"Castle Project Development List" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected] 
<mailto:castle-project-devel%[email protected]> .
For more options, visit this group at 
http://groups.google.com/group/castle-project-devel?hl=en.

 

-- 
You received this message because you are subscribed to the Google Groups 
"Castle Project Development List" 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-devel?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"Castle Project Development List" 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-devel?hl=en.

<<image001.png>>

Reply via email to