lunes 28 de diciembre de 2009

OTHER_INCOME_EXPENSES_CP???

Aqui hay un diagrama de la tabla en si, esta tabla lo que hace es conectar un voyage_instance, Charter_party con los otherIncomes.

Aqui el diagrama:
La forma de llegar facil a los datos, es por este sql, hice el sql con consultas anidadas para que sea mas facil de leer. aqui esta


BEGIN
DECLARE @idVoyageInstance AS int
SET @idVoyageInstance = 7067

select * from voyage where idRealInstance=@idVoyageInstance;
select * from OTHER_INCOME_EXPENSES_CP where idvoyageinstance=@idVoyageInstance;
select * from OTHER_INCOME_EXPENSES_INFO where id in (
select idOtherIncome from OTHER_INCOME_EXPENSES_CP where idvoyageinstance=@idVoyageInstance
);

select * from EXPENSE_DETAIL where idinfo in (
select id from OTHER_INCOME_EXPENSES_INFO where id in (select idOtherIncome from OTHER_INCOME_EXPENSES_CP where idvoyageinstance=@idVoyageInstance)
);

select * from EXPENSE_ITEM where id in (
select iditem from EXPENSE_DETAIL where idinfo in (
select id from OTHER_INCOME_EXPENSES_INFO where id in (select idOtherIncome from OTHER_INCOME_EXPENSES_CP where idvoyageinstance=@idVoyageInstance)
)
);
END
Eso por ahora. si bien las realaciones son medios bestias, funcionan.

Importante: ojo con el mapeo de estas clases, se usa <map> para mepear la tabla OTHER_INCOME_EXPENSES_CP, y en la clase se usa un Idictionary, y no una lista como cuando se mapea de 1...n o n...1