代码之家  ›  专栏  ›  技术社区  ›  freddoo

亚音速预加载对象和子对象

  •  0
  • freddoo  · 技术社区  · 17 年前

    我想用亚音速的子图加载一个对象列表。我知道如何使用linq to sql和dataloadOptions

    我有这个图表

    产品 -位置 价格

    new select().from().where(product.columns.id).isequalto(product id).executeSingle();

    我想为我的产品对象预加载位置和价格,这样他们就不会懒惰地加载导致许多查询。

    谢谢

    1 回复  |  直到 17 年前
        1
  •  1
  •   Rick Rat    17 年前

    我用的是亚音速的储物柜记录,这是“主要”的poco。然后,我对那些在选择属性时加载其他类的类进行分区。此外,从数据库中加载一条记录比同时加载所有记录更快、更容易。

    Partial Public Class Book
    
        Private _Author as Database.Author 
        Property Author() as Database.Author
          Get
             If _Author is nothing then
               ' Load the author class here.
             End if
             return _Author
          End get
          Set
             '....
          End Set
        End Property
    
    End Class
    
    推荐文章