In what scenarios would I need to use the CREATEREF, DEREF and REF keywords?

后端 未结 2 1531
我在风中等你
我在风中等你 2021-01-15 00:31

This question is about why I would use the above keywords. I\'ve found plenty of MSDN pages that explain how. I\'m looking for the why.

What query would I be tryin

相关标签:
2条回答
  • 2021-01-15 01:03

    Look at this post

    One of the benefits of references is that it can be thought as a ‘lightweight’ entity in which we don’t need to spend resources in creating and maintaining the full entity state/values until it is really necessary. Once you have a ref to an entity, you can dereference it by using DEREF expression or by just invoking a property of the entity

    0 讨论(0)
  • 2021-01-15 01:21

    TL;DR - REF/DEREF are similar to C++ pointers. It they are references to persisted entities (not entities which have not be saved to a data source).

    Why would you use such a thing?: A reference to an entity uses less memory than having the DEFEF'ed (or expanded; or filled; or instantiated) entity. This may come in handy if you have a bunch of records that have image information and image data (4GB Files stored in the database). If you didn't use a REF, and you pulled back 10 of these entities just to get the image meta-data, then you'd quickly fill up your memory.

    I know, I know. It'd be easier just to pull back the metadata in your query, but then you lose the point of what REF is good for :-D

    0 讨论(0)
提交回复
热议问题