tags:

views:

250

answers:

2

Hello Everybody,

I am using Linq query and call method Like..

oPwd = objDecryptor.DecryptIt((c.Password.ToString())

it will return null value.

Means this will not working.

how I Resolve this.

Thanks..

var q =
    from s in db.User
    join c in db.EmailAccount on s.UserId equals c.UserId
    join d in db.POPSettings 
        on c.PopSettingId equals d.POPSettingsId
    where s.UserId == UserId && c.EmailId == EmailId
    select new
    {
        oUserId = s.UserId,
        oUserName = s.Name,
        oEmailId = c.EmailId,
        oEmailAccId = c.EmailAccId,
        oPwd = objDecryptor.DecryptIt(c.Password.ToString()),
        oServerName = d.ServerName,
        oServerAdd = d.ServerAddress,
        oPOPSettingId = d.POPSettingsId,
    };
+1  A: 

This has nothing about Linq query. you need to debug method objDecryptor.DecryptIt

Andrey
but i can't go into this linq query..
Jitendra Jadav
You can add breakpoint to DecryptIt method and you'll see why it returns null.
Fedor
When I am debuging at that time it direct pass to this query sohow I Comes to Know ..But the objDecryptor.DecryptIt it's working properly.
Jitendra Jadav
It has *everything* to do with LINQ if it is trying to format it as TSQL...
Marc Gravell
...then test it on its own.
Cory Larson
I will check all the way but i am getting confusion..
Jitendra Jadav
@Jitendra Jadav please, try to concentrate and ask question from beginning to end as clear as possible. Please try to use English better. i am really lost.
Andrey
+2  A: 

If that is LINQ-to-SQL or EF, you'll need to break it into steps (as it can't execute that at the DB). For example:

    var q = 
        from s in db.User
        join c in db.EmailAccount on s.UserId equals c.UserId
        join d in db.POPSettings on c.PopSettingId equals d.POPSettingsId
        where s.UserId == UserId && c.EmailId == EmailId
        select new
        {
            oUserId = s.UserId,
            oUserName = s.Name,
            oEmailId = c.EmailId,
            oEmailAccId = c.EmailAccId,
            oPwd = c.Password,
            oServerName = d.ServerName,
            oServerAdd = d.ServerAddress,
            oPOPSettingId = d.POPSettingsId,
        };

then use AsEnumerable() to break "composition" against the back-end store:

var query2 = from row in q.AsEnumerable()
             select new
             {
                row.oUserId,
                row.oUserName,
                row.oEmailId,
                row.oEmailAccId,
                oPwd = objDecryptor.DecryptIt(row.oPwd),
                row.oServerName,
                row.oServerAdd,
                row.oPOPSettingId
            };
Marc Gravell
Thahk you very much...
Jitendra Jadav