EntityView

Posts   
 
    
Sjoeii
User
Posts: 12
Joined: 24-Oct-2014
# Posted on: 06-Nov-2014 16:18:33   

Hi,

I made myself a view:


SELECT U.Id, EV.Id, SUM(Datediff(dd, StartDate, EndDate) 
    + CASE WHEN Datepart(dw, StartDate) = 7 THEN 1 ELSE 0 END 
    - (Datediff(wk, StartDate, EndDate) * 2 ) 
    - CASE WHEN Datepart(dw, StartDate) = 1 THEN 1 ELSE 0 END + 
    - CASE WHEN Datepart(dw, EndDate) = 1 THEN 1 ELSE -1 END +
    - CASE WHEN EV.HalfDaysIncluded = 1 THEN 0.5 ELSE 0
    END ) as days
from EmployerVacation as EV, [User] as U
where U.Id = EV.UserId and EV.UserId = 3
group by U.Id, EV.Id;

Now i did the stuff to add him to my llblgen project.

now my problem is that i can't seem to get my datasources working (from records outside my view) (i want to add a full name from another table in there) (wich is not working atm)

the reason i don't really understand what is going wrong is the fact i can do the thing i am trying when i have multiple EntityTables wich are linked in the database trough <table_name>.<entity_name>

i got my Readercode here:



            var filter = new PredicateExpression();
            filter.AddWithAnd(EmployerVacationDayFields.UserId == EmployerFields.Id);
            filter.AddWithAnd(EmployerVacationDayFields.Id == EmployerVacationFields.Id);

            var relation = new RelationCollection();
            relation.Add(EmployerVacationDayEntity.Relations.EmployerEntityUsingUserId);

            var sorter = new SortExpression();

            var employerVacation = new EmployerVacationDayCollection();
            employerVacation.GetMulti(filter, -1, sorter, relation);

            return employerVacation;

this bit gives an server error also:


filter.AddWithAnd(EmployerVacationDayFields.Id == EmployerVacationFields.Id);

i hope i am clear about it all flushed if not please ask in easy words cos i am a LLBLGen Noob

thanks for your help already

Sjoeii

Walaa avatar
Walaa
Support Team
Posts: 14994
Joined: 21-Aug-2005
# Posted on: 07-Nov-2014 07:33:25   

this bit gives an server error also:

Code:

filter.AddWithAnd(EmployerVacationDayFields.Id == EmployerVacationFields.Id);

What's the error?

Sjoeii
User
Posts: 12
Joined: 24-Oct-2014
# Posted on: 10-Nov-2014 08:50:49   

the first problem is actually that i cannot find my relation add's somehow it seems the "EmployerEntityUsingUserId" doesn't excist. i also get don't get any gernerated code from the point "relations." maybe i did something wrong with my LLBLGen Pro 3.5 db update?

(because "EmployerEntityUsingUserId" does excists in my other readers).

also i keep getting the error that my Employer.Id cannot be bound?

i probebly do something wrong i just don't see what

Sjoeii
User
Posts: 12
Joined: 24-Oct-2014
# Posted on: 10-Nov-2014 09:31:22   

The multi-part identifier "AB - HolidayScheduler - Trunk.dbo.EmployerVacationDays.UserId" could not be bound. The multi-part identifier "AB - HolidayScheduler - Trunk.dbo.EmployerVacationDays.Id" could not be bound. The multi-part identifier "AB - HolidayScheduler - Trunk.dbo.EmployerVacation.Id" could not be bound. The multi-part identifier "AB - HolidayScheduler - Trunk.dbo.EmployerVacationDays.days" could not be bound. The multi-part identifier "AB - HolidayScheduler - Trunk.dbo.EmployerVacationDays.Id" could not be bound. The multi-part identifier "AB - HolidayScheduler - Trunk.dbo.EmployerVacationDays.UserId" could not be bound.

I get these errors

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39888
Joined: 17-Aug-2003
# Posted on: 10-Nov-2014 10:25:32   

Your view has 3 columns: U.Id, EV.Id and Days, and you have to alias one 'Id' as the name is a duplicate. I'm not sure which name is mapped onto the view you specified as sql in the startpost.

Please enable DQE tracing (see: http://www.llblgen.com/documentation/4.2/LLBLGen%20Pro%20RTF/hh_goto.htm#Using%20the%20generated%20code/gencode_troubleshootingdebugging.htm#preface) to see the SQL being generated. That should give more insights in what's going on/wrong.

Frans Bouma | Lead developer LLBLGen Pro
Sjoeii
User
Posts: 12
Joined: 24-Oct-2014
# Posted on: 24-Nov-2014 08:48:29   

I'm really sorry for my late response and reading I was hit on my head on a Rugby training and i had an headconcussion. so this is kinda the first day I am at a computer again. i going to try de DQE tracing today and will look @ the duplicate ID fields.

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 25-Nov-2014 07:03:13   

Sjoeii wrote:

I'm really sorry for my late response and reading I was hit on my head on a Rugby training and i had an headconcussion. so this is kinda the first day I am at a computer again.

Ouch! frowning I hope you get better.

Sjoeii wrote:

Ii going to try de DQE tracing today and will look @ the duplicate ID fields.

Another thing that seems to be the problem is that, as I see, you mapped your database view to an Entity. That's not the problem, but the fact that that entity don't have any explicit relation to Employee entity in your LLBLGen project. You can add such relation and then the relation will be generated (after you re-generate code). Then you can use it in your own code as your previous post.

Another thing you can do is to manually create the relation in the code:

relation.Add(new EntityRelation(...));

What to put in the parenthesis? That depends on what are the fields you want to link. I don't see any EmployeeId in your view, so I don't know what field you want to use to make the relation.

David Elizondo | LLBLGen Support Team
Sjoeii
User
Posts: 12
Joined: 24-Oct-2014
# Posted on: 25-Nov-2014 08:51:16   

o thank you! yeah still really sorry. i remade a view with a slightly better sql query stuck_out_tongue_winking_eye now it kinda works still needs some tweaking but i learned something new thanks to your latest point! have been playing with it a bit already and it seems i can make it work now simple_smile thank you for that!

you've been really helpfull the pas few weeks and i think my questions have been anwserd according to my current post!

thanks again!