Say I have two tables like this.
TBL_WORKREQUEST
ID - PK/INT/AUTOGENERATED
TITLE - VARCHAR(30)
GROUPID - INT (FK - TBL_GROUP.ID)
TBL_GROUP
ID - PK/INT/AUTOGENERATED
TITLE - VARCHAR(30)
Now say I want to do a prefetch on a group part:
IPrefetchPath wrPreFetch = new PrefetchPath((int)EntityType.WorkRequestEntity);
wrPreFetch.Add(WorkRequestEntity.PrefetchPathGroup);
WorkRequestCollection workCol = new WorkRequestCollection();
workCol.GetMulti(exp1,-1,null,null,wrPreFetch,-1,-1);
Say there are **ONLY **three groups ID (1,2,3), and say there are 500 work requests.
You expect the SQL generated to do something like GroupID IN (@GroupID1,@GroupID2,@GroupID3) @GroupID1 = 1 etc.. .
However it doesnt it does:
GROUPID IN (@GroupID1,.............,@GroupID500)
In other words it pumping out massive SQL queries when it only need to retrieve the distinct group IDs. Do you follow?
In real scenario I have only 10 groups or so, however it's doing based on number of rows of main entity.
Generated Sql query:
Query: SELECT [sysdev].[tbl_Group].[GroupID] AS [GroupId], [sysdev].[tbl_Group].[GroupName], [sysdev].[tbl_Group].[Active], [sysdev].[tbl_Group].[DefaultDefTypeID] AS [DefaultDefTypeId] FROM [sysdev].[tbl_Group] WHERE ( ( [sysdev].[tbl_Group].[GroupID] IN (@GroupId1, @GroupId2, @GroupId3, @GroupId4, @GroupId5, @GroupId6, @GroupId7, @GroupId8, @GroupId9, @GroupId10, @GroupId11, @GroupId12, @GroupId13, @GroupId14, @GroupId15, @GroupId16, @GroupId17, @GroupId18, @GroupId19, @GroupId20, @GroupId21, @GroupId22, @GroupId23, @GroupId24, @GroupId25, @GroupId26, @GroupId27, @GroupId28, @GroupId29, @GroupId30, @GroupId31, @GroupId32, @GroupId33, @GroupId34,
...
@GroupId1821, @GroupId1822, @GroupId1823, @GroupId1824, @GroupId1825, @GroupId1826, @GroupId1827, @GroupId1828, @GroupId1829, @GroupId1830, @GroupId1831, @GroupId1832)))
Parameter: @GroupId1 : Int32. Length: 0. Precision: 10. Scale: 0. Direction: Input. Value: <undefined value>.
....
Parameter: @GroupId54 : Int32. Length: 0. Precision: 10. Scale: 0. Direction: Input. Value: <undefined valu
Was it really necessary to post all the parameters? -- Otis