Home
Help
Register
Log in

Search

 
   Active Threads  

You are here: Home > LLBLGen Pro > LLBLGen Pro Runtime Framework> Fetch DataTable without a strongly typed entity
 

Pages: 1
LLBLGen Pro Runtime Framework
Fetch DataTable without a strongly typed entity
Page:1/1 

  Print all messages in this thread  
Poster Message
egutierrez
User



Location:

Joined on:
12-Nov-2018 16:43:35
Posted:
7 posts
# Posted on: 16-Mar-2019 23:12:25.  
SD.LLBLGen.Pro.ORMSupportClasses: 4.2.20160929
SD.LLBLGen.Pro.DQE.SqlServer: 4.2.20160929
.NET Framework 4.6.1
Sql Server 12.0.5207.0 (2012)

Hi,

I need to get some DataTables for some tables, but the thing is that I can't use the strongly typed entities or fields to do the query.

For example, if I know the entity is called CustomerEntity and the table is called Customer with some fields like Id, Name, and so on.

So, I would need to query something like SELECT Id, Name FROM Customer and get a DataTable.

I can't use the CustomerEntity or the fields in the code because this is a dynamic feature of the application so I know the names because they are in a configuration repository.

Something like:

Code:
var entityName = "CustomerEntity";
var fieldsToQuery = new string[] {"Id", "Name"};

var dataTable = SomeMethodToGetDataTable(entityName, fieldsToQuery);


I know there is FetchAsDataTable() extension method but I don't know how to create a DynamicQuery without using strongly typed entities and fields. I need to create the query only with names as a string.

I understand this is not a normal use of the library and tried to simplify the example but this is something it is required by the application.

Thanks.
  Top
DvK
User



Location:
Delft (centre), Netherlands
Joined on:
22-Mar-2006 10:43:57
Posted:
292 posts
# Posted on: 17-Mar-2019 16:10:36.  
You can fetch a datatable with only the fields you want by using a ResultSetFields object. Use this object to define an array of EntityField, and then fetch by the FetchTypedList method of Adapter.

http://llblgen.com/Documentation/5.5/LLBLGen%20Pro%20RTF/Using%20the%20generated%20code/Adapter/Using%20TypedViews,%20TypedLists%20and%20Dynamic%20Lists/gencode_usingdynamiclists_adapter.htm


  Top
Pages: 1  


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

Version: 2.1.12172008 Final.