Can not fetch collection with prefetch path

Posts   
 
    
kievBug
User
Posts: 105
Joined: 09-Jan-2009
# Posted on: 01-Apr-2014 22:01:55   

Hey guys,

I have a problem with fetching a collection of objects using DataAccessAdapter.GetCollection method when passing a filter and a prefetch path for M:N property.

I'm using Sql Server 2005, Llblgen version 3.1 Final (Sep 30th, 2011)

File versions: SD.LLBLGen.Pro.ORMSupportClasses.NET20.dll version 3.1.11.1129 SD.LLBLGen.Pro.DQE.SqlServer.NET20.dll version 3.1.11.0706

The source code, llblgen project and database can be found here https://www.dropbox.com/s/mqt3hqfy7d8cd5l/Sources.zip

I've tried like this



            using (var adapter = new DataAccessAdapter())
            {
                var subjects = new EntityCollection<SystemGroupEntity>();
                adapter.FetchEntityCollection(subjects, null);

                var filter = new FieldCompareRangePredicate(SystemGroupFields.Id, null, subjects.Select(s => s.Id).ToArray()) & SystemGroupFields.Deleted == 0;
                var bucket = new RelationPredicateBucket(filter);
                bucket.Relations.Add(SystemGroupEntity.Relations.GetSuperTypeRelation());
                bucket.Relations.Add(GroupEntity.Relations.GetSuperTypeRelation());

                var systemGroups = new EntityCollection<SystemGroupEntity>();
                adapter.FetchEntityCollection(systemGroups, new RelationPredicateBucket(filter), new PrefetchPath2(EntityType.SystemGroupEntity)
                {
                    SystemGroupEntity.PrefetchPathMembers,
                });

                Console.WriteLine("Loaded {0} records.", systemGroups.Count);
                Console.ReadLine();
            }


and also without adding relations to supertypes and it still doesn't work.

Thanks, Anton

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 02-Apr-2014 08:15:56   

Hi Anton,

What exactly doesn't work? There are some points I noticed:

1) Your LLBLGen version is quite old. The actual Designer build for v3.1 is March 12th, 2012. The RTL is 3.1.12.1015. So, update to the latest version and regenerate again.

2) You don't need to add the inheritance relations as they are added implicitly.

3) I downloaded your repro solution, restored the db backup, opened the LLBLGen project and regenerate code, then I fixed some references and remove the relations to superTypes, then I run the test. I got 152 records from the result. So, it works.

4) I fixed the references on your PrefetchTest.csproj as you were pointing to v3.5 assemblies instead of v3.1. Maybe that's the problem. Here is the part of your vsnet project with the wrong references:

    <Reference Include="SD.LLBLGen.Pro.DQE.SqlServer.NET20, Version=3.5.0.0, Culture=neutral, PublicKeyToken=ca73b74ba4e3ff27, processorArchitecture=MSIL">
      <SpecificVersion>False</SpecificVersion>
      <HintPath>..\..\..\..\..\Intelex.NET\03-System\Lib\SD.LLBLGen.Pro.DQE.SqlServer.NET20.dll</HintPath>
    </Reference>
    <Reference Include="SD.LLBLGen.Pro.ORMSupportClasses.NET20, Version=3.5.0.0, Culture=neutral, PublicKeyToken=ca73b74ba4e3ff27, processorArchitecture=MSIL">
      <SpecificVersion>False</SpecificVersion>
      <HintPath>..\..\..\..\..\Intelex.NET\03-System\Lib\SD.LLBLGen.Pro.ORMSupportClasses.NET20.dll</HintPath>
    </Reference>

Also, at your PrefetchTest.csproj, you don't need to add reference to SD.LLBLGen.Pro.DQE.SqlServer.NET20. You just need ORMSupportClasses and LinqSupportClasses (if you will make Linq2LLBL queries).

Hope that helps wink

David Elizondo | LLBLGen Support Team
kievBug
User
Posts: 105
Joined: 09-Jan-2009
# Posted on: 02-Apr-2014 15:22:42   

Ok, I've checked and for 3.5 it works fine. But for 3.1 it doesn't work.

Upgrade is theoretically possible, but it requires a lot of efforts for us: - changing the templates - we have our own templates; - a lot of testing

Is it possible to get a patch for 3.1?

Thanks, Anton

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 02-Apr-2014 22:13:36   

You don't need to upgrade to 3.5, just use the latest release of v.3.1, and make sure you reference the correct version of the runtime libraries.

kievBug
User
Posts: 105
Joined: 09-Jan-2009
# Posted on: 02-Apr-2014 22:48:51   

Ok it works.

Thanks, Anton