As a newbie, I am trying to look at the behaviour of LLblgen with MS-SQL.
I have a small sample code in a Windows Forms application that retrieves 10 records from the Customers table from the AdventureWorks database (not Northwind this time for a change). I also use a prefetch for the Salesterritory object:
bindingSource1.DataSource = entityCollection1;
dataGridView1.DataSource = bindingSource1;
bindingNavigator1.BindingSource = bindingSource1;
DataAccessAdapter ds = new DataAccessAdapter();
PrefetchPath2 path = new PrefetchPath2((int)EntityType.CustomerEntity);
path.Add(CustomerEntity.PrefetchPathSalesTerritory );
ds.FetchEntityCollection(entityCollection1, null, 0, null, path,3, 10);
CustomerEntity cust = (CustomerEntity)entityCollection1[0];
SalesTerritoryEntity s = new SalesTerritoryEntity();
s = cust.SalesTerritory;
To my surprise the generated SQL does not use a inner join for the two tables but makes two separate select calls, which is neat I guess.
However, beside about 10 useful commands I see about 90 commands that seems to be unnecessary. The following three statements are executed about 30 times:
SET @ReturnValue = REPLICATE('0', 8 - DATALENGTH(@ReturnValue)) + @ReturnValue;
RETURN (@ReturnValue);
SET @ReturnValue = CONVERT(varchar(8), @Value);
Do I need to configure something different or is this unavoidable?