1
I made that class:
public class ConexaoParametrosTFV
{
public ConexaoParametrosTFV()
{
if ((SessaoUtil.Recuperar("ConexaoTFV") == null))
{
AgaxturCmsEntities db = new AgaxturCmsEntities();
var resultado = (from a in db.TbClientes
where a.CdCliente == 1 && a.Ativo == "S"
select new {
a.CultureTripoint,
a.LoginTripoint,
a.SenhaTripoint,
a.SalesChannelTripoint,
a.DepartmentIdTripoint,
a.EntityIdTripoint }).First();
SessaoUtil.SalvarSession("ConexaoTFV", "resultado");
}
}
}
I need now in another class, pick up everything you’ve clicked on Session and download into six variables.
How do I do it?
SessaoUtil.SalvarSession("ConexaoTFV", "resultado");
seems to be wrong,"resultado"
is a string, and does not reference the variableresultado
.– Miguel Angelo
I didn’t even notice it
– pnet
Saves the object in Session, then arrow each variable with the value of each object property.
– Tony
That’s my question. How do I do it? That’s the reason for my post.
– pnet
var recovering = Sessaoutil.Recover("Conexaoftv"); var1 = recovering.var1; var2 = recovering.var2;
– Tafarel Chicotti
Doesn’t work that way
– pnet
instead of using var, use Dynamic, when you use var it creates an Anonymous and Voce will not know at the time of recovering what is the type of your object. Use Dynamic when capturing Tbclientes result
– Roger Barretto
@Roger: now that OP is using anonymous class objects. Still, I wouldn’t recommend using
dynamic
, rather a class to represent the object.– Miguel Angelo
@Miguelangelo I agree with you 100% but this would set a precedent so that he had to declare a new class for each different query in the Views.
– Roger Barretto
Yes, this is what happens for example with Viewmodel and Domainmodel classes. Each has a representative class, and this makes the project more consistent.
– Miguel Angelo
@Roger: Even if I disagree with you, I could add an answer to your solution... it’s a valid solution. = D
– Miguel Angelo
@Miguelangelo, the Uri solution does what I suggested, it should work. I agree that the ideal is to use a Viewmodel for any and all MVC views but since the little friend is not using I usually be pragmatic in giving the solution in line with his head. :)
– Roger Barretto