Click here to Skip to main content
15,890,282 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: mvc book Pin
cyber_addicted21-May-13 20:15
cyber_addicted21-May-13 20:15 
QuestionAccess Database, ASP/C# Drop Down List populating a Drop Down List Pin
WickedFooker17-May-13 15:00
WickedFooker17-May-13 15:00 
AnswerRe: Access Database, ASP/C# Drop Down List populating a Drop Down List Pin
Richard Deeming20-May-13 2:02
mveRichard Deeming20-May-13 2:02 
GeneralRe: Access Database, ASP/C# Drop Down List populating a Drop Down List Pin
WickedFooker20-May-13 5:34
WickedFooker20-May-13 5:34 
AnswerRe: Access Database, ASP/C# Drop Down List populating a Drop Down List Pin
cyber_addicted21-May-13 0:53
cyber_addicted21-May-13 0:53 
Questionhow to write sql's not in operator using linq to entities 4.0 Pin
indian14317-May-13 7:14
indian14317-May-13 7:14 
AnswerRe: how to write sql's not in operator using linq to entities 4.0 Pin
R. Giskard Reventlov20-May-13 6:11
R. Giskard Reventlov20-May-13 6:11 
QuestionEF:How to link Expressions in order to generate an OR/AND Linq query Pin
Clodetta del Mar17-May-13 1:44
Clodetta del Mar17-May-13 1:44 
Hi @all Smile | :)
I´m new to Expressiontrees and their invocation...
but they seem to be really mighty and useful...
I know that one can extend expressiontrees, but up until now I wasn´t been able to fully comprehend how to do that..
practically I want to "convert" this lambda into an expressiontree:
C#
(o => o.LognName == name) 

and I do that by this Wink | ;-)
C#
Expression<Func<Users_UserAccount, bool>> whereLogonName = LinqExtender.DynamicLinq.BuildOrTree<Users_UserAccount, string>(LogonName, UserAccount => UserAccount.LogonName);

so far so good. I also know that I now can query multiple users... fine thing... D'Oh! | :doh:
what´s really cool about this is, that expressiontree returns whatever you need takes any type of parameter... a fine thing would be if I was able to pass the correct "sql/linq" query to it... Dead | X|
to be honestly, my desire goes for this:
C#
(o => o.LognName == name && o.LogonPW == "12345") //dumb pw

now my question is:
how to link different params in an expressiontree?
I heard about
C#
Expression.Or
Expression.And

and am using it, but I feel that this does not function properly and as desired...
here´s my function of the treebuild:
C#
public static Expression<Func<TValue, bool>> BuildOrTree<TValue, TCompareAgainst>(
        IEnumerable<TCompareAgainst> wantedItems,
        Expression<Func<TValue, TCompareAgainst>> convertBetweenTypes)
        {
            ParameterExpression inputParam = convertBetweenTypes.Parameters[0];

            Expression binaryExpressionTree = BuildBinaryOrTree(wantedItems.GetEnumerator(), convertBetweenTypes.Body, null);

            return Expression.Lambda<Func<TValue, bool>>(binaryExpressionTree, new[] { inputParam });
        }

I've found that on the interwebs...it´s NOT mine...but with very few changes, I've also implemented the AND-equivalent. whoa... Laugh | :laugh: what an effort... Shucks | :-\
so, to put long things short:
how to combine the both of them to achieve the desired query?

thanks in advance!
what a cool community Thumbs Up | :thumbsup: Smile | :)
[edit]
forgot that:
C#
private static Expression BuildBinaryOrTree<T>(
        IEnumerator<T> itemEnumerator,
        Expression expressionToCompareTo,
        Expression expression)
        {
            if (itemEnumerator.MoveNext() == false)
                return expression;

            ConstantExpression constant = Expression.Constant(itemEnumerator.Current, typeof(T));
            BinaryExpression comparison = Expression.Equal(expressionToCompareTo, constant);

            BinaryExpression newExpression;

            if (expression == null)
                newExpression = comparison;
            else
                newExpression = Expression.OrElse(expression, comparison);

            return BuildBinaryOrTree(itemEnumerator, expressionToCompareTo, newExpression);
        }

sorry Big Grin | :-D
ps:hopefully I dove into the correct forum... Sniff | :^)


aaargh, ultraedit:
addendum:
LogonName in the lambda was of type string, the Expressionparam is of type string[]
addendum 458:
as one might suspect:my math knowledge is not that sophisticated... the term binarytree is familiar to me since 4 days or 5... D'Oh! | :doh:
but, i´m somewhat able to use it...
just like luke skywalker and his lasersword...
he is capable to use it as a weapon, but is he able to assemble it!? Big Grin | :-D Cool | :cool:

modified 17-May-13 9:25am.

Answer[solved?]the concrete calling...the priority problem Pin
Clodetta del Mar17-May-13 2:51
Clodetta del Mar17-May-13 2:51 
QuestionHow to use different fonts? Pin
Jassim Rahma16-May-13 10:15
Jassim Rahma16-May-13 10:15 
AnswerRe: How to use different fonts? Pin
Richard MacCutchan16-May-13 21:20
mveRichard MacCutchan16-May-13 21:20 
AnswerRe: How to use different fonts? Pin
Jitendra Parida - Jeetu20-May-13 1:02
Jitendra Parida - Jeetu20-May-13 1:02 
AnswerRe: How to use different fonts? Pin
wikizhao27-May-13 21:18
wikizhao27-May-13 21:18 
QuestionHow to Open Datalist Link Button in New Tab in browser Pin
Member 998801815-May-13 21:35
Member 998801815-May-13 21:35 
AnswerRe: How to Open Datalist Link Button in New Tab in browser Pin
Richard Deeming16-May-13 1:32
mveRichard Deeming16-May-13 1:32 
Questionc# code to download .xlsm file Pin
Sachin Adsul15-May-13 21:20
Sachin Adsul15-May-13 21:20 
AnswerRe: c# code to download .xlsm file Pin
ZurdoDev21-May-13 10:26
professionalZurdoDev21-May-13 10:26 
QuestionPlease Help With Various Methods of Optical Character Recognition which can be used for successful Conversion?? Pin
Kaushal Behere15-May-13 20:52
professionalKaushal Behere15-May-13 20:52 
QuestionHtml to PDF Pin
Denzil_Sdn15-May-13 19:56
Denzil_Sdn15-May-13 19:56 
AnswerRe: Html to PDF Pin
Mohammed Hameed18-May-13 10:59
professionalMohammed Hameed18-May-13 10:59 
GeneralRe: Html to PDF Pin
Denzil_Sdn19-May-13 20:37
Denzil_Sdn19-May-13 20:37 
GeneralRe: Html to PDF Pin
Mohammed Hameed19-May-13 20:46
professionalMohammed Hameed19-May-13 20:46 
Questionasp.net with silverlight Pin
junkyy15-May-13 11:01
junkyy15-May-13 11:01 
AnswerRe: asp.net with silverlight Pin
ZurdoDev21-May-13 10:28
professionalZurdoDev21-May-13 10:28 
QuestionChat Box Component Pin
Member 1005410915-May-13 2:33
Member 1005410915-May-13 2:33 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.