New Posts New Posts RSS Feed: Help with C# translation
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Help with C# translation

 Post Reply Post Reply
Author
rclarke View Drop Down
Groupie
Groupie


Joined: 14-Jun-2007
Location: United States
Posts: 69
Post Options Post Options   Quote rclarke Quote  Post ReplyReply Direct Link To This Post Topic: Help with C# translation
    Posted: 27-Jul-2010 at 1:11pm
Can someone please show me the VB translation for the following C# line of code:
 
QueryFilters.AddFilter<User>(q => q.Where(u => u.UserName == Principal.Identity.Name));
I tried using InstantVB which does not produce the correct translation:
QueryFilters.AddFilter(Of User)(Function(q) q.Where(Function(u) u.UserName = Principal.Identity.Name))

Any help would be greatly appreciated.
Back to Top
GregD View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 09-May-2007
Posts: 374
Post Options Post Options   Quote GregD Quote  Post ReplyReply Direct Link To This Post Posted: 28-Jul-2010 at 2:25pm
Not sure, but it looks like the InstantVB translation may be missing a pair of parentheses: 
 
THIS:
     QueryFilters.AddFilter(Of User)(Function(q) (q.Where(Function(u) u.UserName = Principal.Identity.Name))) 
 
NOT THIS:
     QueryFilters.AddFilter(Of User)(Function(q) q.Where(Function(u) u.UserName = Principal.Identity.Name))
Back to Top
rclarke View Drop Down
Groupie
Groupie


Joined: 14-Jun-2007
Location: United States
Posts: 69
Post Options Post Options   Quote rclarke Quote  Post ReplyReply Direct Link To This Post Posted: 28-Jul-2010 at 3:24pm
Thanks For trying to help Greg but your suggestion did not fix the problem. In fact I get the same error any time I try
 
aUser = pManager.Users.Where(Function(u) u.UserName = pUsername).FirstOrNullEntity()
The error is "Overloaded resolution failed because no accessable 'Where' can be called with these arguements.
I have tried a number of translators and all of them translate the C# code with the same result. So several translators think 
that the VB code is correct yet it does not work, very frustrating...
Back to Top
davidklitzke View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 14-Jun-2007
Posts: 715
Post Options Post Options   Quote davidklitzke Quote  Post ReplyReply Direct Link To This Post Posted: 28-Jul-2010 at 3:52pm
Perhaps you are missing an "Imports" statement.  See:
 
Back to Top
rclarke View Drop Down
Groupie
Groupie


Joined: 14-Jun-2007
Location: United States
Posts: 69
Post Options Post Options   Quote rclarke Quote  Post ReplyReply Direct Link To This Post Posted: 28-Jul-2010 at 4:15pm
The proper imports are there and the Where does show up with all of the overloads of which there are 4. There has to be something about how the parameters are specified at least that's what the compiler is complaining about. I guess I'll just rewrite the queries as LINQ queries and not try to use the Lambda expressions but it would be nice of I could figure this out and use the Lambda's
Back to Top
rclarke View Drop Down
Groupie
Groupie


Joined: 14-Jun-2007
Location: United States
Posts: 69
Post Options Post Options   Quote rclarke Quote  Post ReplyReply Direct Link To This Post Posted: 28-Jul-2010 at 4:42pm
Problem Solved! I refreshed my model from the database and regenerated and the problem went away. Funny thing is that I had made no database changes. I don't know what caused the original propblem but I'm good now. Thanks to all for the help.
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down