Home
Help
Register
Log in

Search

 
   Active Threads  

You are here: Home > LLBLGen Pro > LLBLGen Pro Runtime Framework> Exclude/Include Fields in FetchEntityCollection
 

Pages: 1
LLBLGen Pro Runtime Framework
Exclude/Include Fields in FetchEntityCollection
Page:1/1 

  Print all messages in this thread  
Poster Message
softsurgeon
User



Location:
Manchester, UK
Joined on:
11-Dec-2008 10:57:38
Posted:
10 posts
# Posted on: 05-Oct-2019 15:02:58.  

Hi,

I am trying to fetch only TWO fields from database but following code is returning all fields. Can someone point out what I am doing wrong?

public IHttpActionResult Get()
        {

            var includedFields = new ExcludeIncludeFieldsList();
            includedFields.ExcludeContainedFields = false;
            includedFields.Add(CourseGroupFields.CourseGroupId);
            includedFields.Add(CourseGroupFields.Name);

            var collection = new EntityCollection<CourseGroupEntity>();
        
            // fetch a collection of coursegroups
            var courseGroups = new EntityCollection<CourseGroupEntity>();
            var sorter = new SortExpression(CourseGroupFields.Name | SortOperator.Ascending);
            
                
            using (var adapter = new DataAccessAdapter())
            {
                
                adapter.FetchEntityCollection(courseGroups, null, 0, sorter, null, includedFields);
                //adapter.FetchExcludedFields(courseGroups, includedFields);
                
            }
                    
            return Ok(courseGroups);
        }
  Top
daelmo
Support Team



Location:
Guatemala City
Joined on:
28-Nov-2005 23:35:24
Posted:
8088 posts
# Posted on: 07-Oct-2019 07:59:30.  
Hi there,

The code looks ok.

- How can you tell that the fields are being fetched? (you see the executed query, to see the real db values inside the entity)

- What LLBLGen version and runtime library version are you using? ( http://www.llblgen.com/TinyForum/Messages.aspx?ThreadID=7722 )


David Elizondo
LLBLGen'ing (articles and code snippets) | linkedin | twitter
 
Top
softsurgeon
User



Location:
Manchester, UK
Joined on:
11-Dec-2008 10:57:38
Posted:
10 posts
# Posted on: 13-Oct-2019 19:22:43.  
Yup, you're right - The code is 100% OK. I got confused as all field names were returned. However, after careful insight, I found that data for only INCLUDED fields was returned.
  Top
daelmo
Support Team



Location:
Guatemala City
Joined on:
28-Nov-2005 23:35:24
Posted:
8088 posts
# Posted on: 14-Oct-2019 08:17:10.  
softsurgeon wrote:
Yup, you're right - The code is 100% OK. I got confused as all field names were returned. However, after careful insight, I found that data for only INCLUDED fields was returned.

Yes, you will always see the fields, the difference is that the data is not fetched so those fields are there but empty (or default values).
Good you figured it out Regular Smiley


David Elizondo
LLBLGen'ing (articles and code snippets) | linkedin | twitter
 
Top
Pages: 1  


Powered by HnD ©2002-2007 Solutions Design
HnD uses LLBLGen Pro

Version: 2.1.12172008 Final.