Hi everybody,
I have an uni-directional One-To-Many indexed collection mapping as
follows:
public class Restaurant : Entity
{
public virtual IList<Category> Categories { get; set; }
...
}
public class Category : Entity
{
public virtual string Name { get; set; }
}
<class name="Restaurant" table="Restaurants" batch-size="10">
<id name="Id" type="System.Int64">
<generator class="seqhilo" />
</id>
<list name="Categories" batch-size="10" cascade="all-delete-
orphan">
<key column="_Restaurant_Id" />
<index column="_IndexOf_Restaurant_Categories" />
<one-to-many class="BeautifulKitchen.Models.Category" />
</list>
...
</class>
for example, I have already had 4 Categories in database:
c0, c1, c2, c3
which belongs to a Restaurant.
if I change the order of them to:
c0, c1, c3, c2
I noticed 4 update statement had been sent to db:
UPDATE Categories SET _Restaurant_Id = null,
_IndexOf_Restaurant_Categories = null WHERE _Restaurant_Id = :p0 AND
Id = :p1;:p0 = 31, :p1 = 41
UPDATE Categories SET _Restaurant_Id = null,
_IndexOf_Restaurant_Categories = null WHERE _Restaurant_Id = :p0 AND
Id = :p1;:p0 = 31, :p1 = 83
UPDATE Categories SET _Restaurant_Id = :p0,
_IndexOf_Restaurant_Categories = :p1 WHERE Id = :p2;:p0 = 31, :p1 =
3, :p2 = 83
UPDATE Categories SET _Restaurant_Id = :p0,
_IndexOf_Restaurant_Categories = :p1 WHERE Id = :p2;:p0 = 31, :p1 =
4, :p2 = 41
is it possible to eliminate the first 2 statements to improve
performance?
Thanks,
Zhibin
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"nhusers" 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/nhusers?hl=en
-~----------~----~----~----~------~----~------~--~---