Is it possible to load only one part of the RAWDAB document I want to get from a document ID, but only some fields fetch should be done. I know that I can call select
by using session.Query
, but then I can not query the document ID, so let me do the session Instead, load it
, but it fetches the whole document Do I need to create an index for this?
You the result transformer to get it
Say you have a "customer" entity
public class customer {public string id {get; Set; } Public string name {get; Set; } Public Address Address {get; Set; } Receive the public string phone number { Set; } Public String Email {get; Set; }}
and you want to load the property of only id and name, you define a result transformer:
public class CustomerNameTransformer: AbstractTransformerCreationTask & lt; Customers & gt; {PUBLIC PENETRATOR TRANSFORMERS () {TransformResults = results = & gt; Select the new customer name VimeModel from the customer {ID = Customer. Id, name = customer.name}; }}
and your "visual model":
public class CustomerNameViewModel {public string id {get; Set; } Public string name {get; Set; }}
With this, you can use the client entity as a "View Customer Name Model" in many ways:
// load Do and transform ID ID by a ViewModelViewModel = session. Load & lt; Customer Name Transformer, Customer Name ViewModel & gt; ("Customer / 1"); // Multiple ID's customer name VimeModel [] Load Models = load by session and transform. Load & lt; Customer Name Transformer, Customer Name ViewModel & gt; (New [] {"customer / 1", "customer / 2"}); // Question and Change List & lt; Customer Name VimeModel & gt; ViewModels = session.Query & lt; Customers & gt; (). With Transforms & lt; Customer Name Transformer, Customer Name ViewModel & gt; () .toList ();
Transformers are executed on the server side before returning to the data client. They are created by the same index creation work which creates index definitions on the server.
You can read more about the result transformer in the document:
Hope it helps!
No comments:
Post a Comment