Click here to Skip to main content
15,887,430 members
Home / Discussions / C#
   

C#

 
GeneralRe: "This command is not available because no document is open." Pin
Tejas Shastri23-Oct-14 4:09
Tejas Shastri23-Oct-14 4:09 
Questionlaunch another Application from memory by C# Pin
iscreen22-Oct-14 0:15
iscreen22-Oct-14 0:15 
AnswerRe: launch another Application from memory by C# Pin
Richard MacCutchan22-Oct-14 0:20
mveRichard MacCutchan22-Oct-14 0:20 
AnswerRe: launch another Application from memory by C# PinPopular
Richard Deeming22-Oct-14 2:45
mveRichard Deeming22-Oct-14 2:45 
GeneralRe: launch another Application from memory by C# Pin
iscreen22-Oct-14 2:57
iscreen22-Oct-14 2:57 
QuestionCalendar Extender Pin
sadmoh21-Oct-14 23:52
sadmoh21-Oct-14 23:52 
Questionusing a Func with dynamic parameters as a query: pros ? cons ? and a few other miscellaneous questions on Func Pin
BillWoodruff21-Oct-14 13:03
professionalBillWoodruff21-Oct-14 13:03 
AnswerRe: using a Func with dynamic parameters as a query: pros ? cons ? and a few other miscellaneous questions on Func Pin
Richard Deeming22-Oct-14 2:41
mveRichard Deeming22-Oct-14 2:41 
Question 1:
In the compiled code, there is no difference between calling an extension method as an extension method, and calling it as a static method.

The main benefit of calling it as an extension method is that it makes chained calls easier to read.
C#
result = Enumerable.Select(Enumerable.OrderBy(Enumerable.Where(Enumerable.GroupBy(source, groupBy), filter), sorting), projection);

// versus:
result = source.GroupBy(groupBy).Where(filter).OrderBy(sorting).Select(projection);


The only time you'll really need to call an extension method as a static method is when you're using dynamic, as the runtime binder doesn't know about extension methods.

Question 2:
You could try passing a list selector to your delegate. However, using dynamic will complicate matters - you can't call extension methods, and you can't use a dynamic parameter in a lambda method.

The only way I could get this to work with a dynamic parameter was to replace the inner lambda method with a call to .Intersect(list).Any():
C#
Func<Student, Func<Student, dynamic>, dynamic, bool> dynMatchFromMultiTypeList = (student, listSelector, itemList) 
    => listSelector(student) != null && Enumerable.Any(Enumerable.Intersect(listSelector(student), itemList));

result = students.Where(student => dynMatchFromMultiTypeList(student, s => s.Scores, new List<int> { 88, 91 }));


However, I'm not sure that really gives you any benefit over:
C#
result = students.Where(student => student.Scores != null && student.Scores.Intersect(new List<int> { 88, 91 }).Any());




"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer


GeneralRe: using a Func with dynamic parameters as a query: pros ? cons ? and a few other miscellaneous questions on Func Pin
BillWoodruff22-Oct-14 6:19
professionalBillWoodruff22-Oct-14 6:19 
GeneralRe: using a Func with dynamic parameters as a query: pros ? cons ? and a few other miscellaneous questions on Func Pin
Richard Deeming22-Oct-14 6:38
mveRichard Deeming22-Oct-14 6:38 
GeneralRe: using a Func with dynamic parameters as a query: pros ? cons ? and a few other miscellaneous questions on Func Pin
BillWoodruff22-Oct-14 7:44
professionalBillWoodruff22-Oct-14 7:44 
Questionspeedtest.net Like result Pin
Jassim Rahma21-Oct-14 10:21
Jassim Rahma21-Oct-14 10:21 
AnswerRe: speedtest.net Like result Pin
Pete O'Hanlon21-Oct-14 10:26
mvePete O'Hanlon21-Oct-14 10:26 
GeneralRe: speedtest.net Like result Pin
Jassim Rahma21-Oct-14 10:31
Jassim Rahma21-Oct-14 10:31 
GeneralRe: speedtest.net Like result Pin
PIEBALDconsult21-Oct-14 10:35
mvePIEBALDconsult21-Oct-14 10:35 
GeneralRe: speedtest.net Like result Pin
Bernhard Hiller22-Oct-14 22:52
Bernhard Hiller22-Oct-14 22:52 
GeneralRe: speedtest.net Like result Pin
PIEBALDconsult21-Oct-14 10:31
mvePIEBALDconsult21-Oct-14 10:31 
Questiontrying to use stored proc @fields in winforms with sql connection. Error procedure or function @Field expects parameter... Pin
Sam 910021-Oct-14 8:34
Sam 910021-Oct-14 8:34 
AnswerRe: trying to use stored proc @fields in winforms with sql connection. Error procedure or function @Field expects parameter... Pin
Richard Deeming21-Oct-14 8:47
mveRichard Deeming21-Oct-14 8:47 
AnswerRe: trying to use stored proc @fields in winforms with sql connection. Error procedure or function @Field expects parameter... Pin
PIEBALDconsult21-Oct-14 9:10
mvePIEBALDconsult21-Oct-14 9:10 
GeneralRe: trying to use stored proc @fields in winforms with sql connection. Error procedure or function @Field expects parameter... Pin
Sam 910021-Oct-14 9:53
Sam 910021-Oct-14 9:53 
GeneralRe: trying to use stored proc @fields in winforms with sql connection. Error procedure or function @Field expects parameter... Pin
PIEBALDconsult21-Oct-14 10:04
mvePIEBALDconsult21-Oct-14 10:04 
GeneralRe: trying to use stored proc @fields in winforms with sql connection. Error procedure or function @Field expects parameter... Pin
Sam 910021-Oct-14 11:38
Sam 910021-Oct-14 11:38 
GeneralRe: trying to use stored proc @fields in winforms with sql connection. Error procedure or function @Field expects parameter... Pin
PIEBALDconsult21-Oct-14 11:48
mvePIEBALDconsult21-Oct-14 11:48 
Answerproblem with multicolumncombo and bindingnavigator movenext ,... Pin
fatemehsoleimani21-Oct-14 4:58
fatemehsoleimani21-Oct-14 4:58 

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.