nabils wrote:
SD.LLBLGen.Pro.DQE.SqlServer.NET20.dll 2.6.8.1114
SD.LLBLGen.Pro.LinqSupportClasses.NET35.dll 2.6.9.220
SD.LLBLGen.Pro.ORMSupportClasses.NET20.dll 2.6.9.116
The authorizer does not seem to be triggered when retrieving data through a LINQ projection.
e.g.
This does not reach a breakpoint in CanLoadEntity overriden method
var employees = new LinqMetaData(_adapter).Employee.Select(e => new Employee {
FirstName = e.FirstName
etc.
}
LLBLGen Pro has two pipelines for fetching data: the entity fetch pipeline and the projection pipeline. The projection pipeline has no optimization code for entities and doesn't know anything about inheritance entities. When you fetch entities the normal way, i.e. without projections, you'll use the entity fetch pipeline.
This pipeline also uses authorizers when determining if an entity is allowed to be fetched. The projection pipeline has no idea what it fetches and therefore can't detect if it has to authorize anything. You use the projection pipeline so nothing is authorized during the fetch. The entity object itself does get the authorizer injected though.
This does reach the breakpoint:
var employees = new LinqMetaData(_adapter).Employee.ToList()
I would also expect CanGetField to be called when I do the e.FirstName above in the projection.
Can this work in this way? Thanks
That's not going to work, as 'e.FirstName' refers to a value in a resultset before it's projected. e.Firstname isn't a property reference on a materialized entity object: it's simply refering to Firstname in the tuples which form the set of entity instances to project.
So no, this can't work simply because the engine which projects the data has no idea what it projects, as the data is simply raw data. For simple queries it might be possible to detect which authorizer to use, but for more complex queries and projections this is impossible.