NHibernate -How to conditionally load data from a column -


We are not using FlintNubrinate. We have a table with a Blob column that we want to conditionally load. . We have referred it as 'lazy' and lazy loading is working fine. Is there a way to not load the data on that column at all on a certain condition? ? Xml version = "1.0" encoding = "utf-8", (hence the property in the related category)

For example, here is the mapping

  & lt? & Gt; & Lt; Hibernate-mapping xmlns = "vase: nhibernate-mapping -2.2" name space = "Blah.blah.blah" assembly = "Blah.blah" & gt; & Lt; Class name = "MyDocument" table = "HEAVY_DOCS" & gt; & Lt; Id name = "id" column = "docnum" type = "decimal" & gt; & Lt; / Id & gt; & Lt; Property Name = "docname" column = "docname" / & gt; & Lt; Property Name = "Description" column = "Description" /> & Lt; Property Name = "doc_data" column = "document_data" lazy = "true" /> & Lt; / Square & gt; & Lt; / Hibernate-mapping & gt;  

and the code below is getting the document

  PrivateIlist & lt; MyDocument & gt; FetchDocuments (IList & lt; String & gt; Postal ID, bool laodData) {if (laodData!) {Docs = (Session.Query & lt; MyDocument & gt; () from the document where docId.Contains (doc.docnum) Select doc) .toList (); } Other {// if Laodetta is false, then the document is not loaded document_data} return docs; }  itemprop = "text"> 

after the way, the way to increase the column selection by our code, using the

estimates . Adjusted code can look like this:

  if (! LaodData) {docs = (from Session.Query & lt document; MyDocument & gt; () where docId.Contains (doc.docnum) Selection dock // full object). Olist (); } Else {Docs = (MyDocument & gt; (; MyDocument & gt;) from the document where the docId.Contains (doc.docnum) NHibernate is called the new MyDocument // selection // that is called DOCNAME = doc.docname, // projection description = doc.details, // id = doc.Id for a "doc_data" LARGE document,}) .Oolist (); }  

With the projections, you can benefit from powerful anconnet, which are built in powerful result transformers which can also cover protected properties Choiroff (including relations) for changes to estimate ...


Comments

Popular posts from this blog

sqlite3 - UPDATE a table from the SELECT of another one -

c# - Showing a SelectedItem's Property -

javascript - Render HTML after each iteration in loop -