EntityTypes and TCriteria in ObjectManager Methods

Ok, today I have many questions.

I have this and it works


var
  LSubscription    : TPubSubscription;
begin
    for LSubscription in LSession.objManager.Find<TPubSubscription>.Where( xxx ).List do
      LSession.objManager.Remove( LSubscription);
end;


now, I want to use this


var
  LSubscription    : TPubSubscription;
begin
    LSubscription := LSession.objManager.Find<TPubSubscription>.Where( xxx );
end;


This makes a compiler error: 
[dcc64 Fehler] Pub.func.Impl.pas(422): E2010 Inkompatible Typen: 'TPubSubscription' und 'Aurelius.Criteria.Base.TCriteria<Pub.dbEntities.TPubSubscription>'

If I change the declaration
var
  LSubscription    : TCriteria<TPubSubscription>;

everything is fine

But why is the first example ok??? And the second not?

And can I work with LSubscription: TCriteria<TPubSubscription>  as good as  LSubscription: TPubSubscription?
With Functions in ObjectManager?

Your first code calls Find<T>.Where.List which returns a TList<TPubSubscription>

Your second code calls Find<T>.Where which returns a TCriteria<TPubSubscription>

They are different types so it's expected you use the correct type when assigning it to a variable.

If I want to have a TPubSubscription, can I use the "UniqueResult"?
Or is something else better?


var
  criteria_var : TCriteria<TPubSubscription>;
  pubsub_var : TPubSubscription;
begin
  search ...
  pubsub_var := criteria_var.UniqueResult


Yes, that's what UniqueResult is for. 

Note that the outcome possibilities are three:

1. The query returns no records. UniqueResult returns nil.
2. The query returns a single record. UniqueResult returns a TPubSubscription object.
3. The query returns two or more records. An exception is raised.