Questions tagged [linq-extensions]

25 questions
1
vote
1 answer

Linq query with join, group and count (extension format)

I have a table, that stores some information and reference (column parent_ID) to parent row in the same table. I need to get list of all records (using Linq extension format) with count of child records. This is SQL query that gives me the desired…
Prokurors
  • 2,458
  • 3
  • 40
  • 65
0
votes
1 answer

Write an extensions method for linq and entity framework

I have a little odd question working by lifting an very old system and replacing 10year old nHibernate with EF. I have trouble formulating some linq extensions for a search page. The thing I want to refactor is this(this code rows is used many times…
0
votes
2 answers

C# byte array contains string inside linq where

I need to check if my byte array contains string in LinQ Where() method. At the moment I have something like: public static bool ContainsSequence(byte[] toSearch, byte[] toFind) { for (var i = 0; i + toFind.Length < toSearch.Length; i++) { …
d3st1ny
  • 75
  • 1
  • 13
0
votes
2 answers

How to extensions join 3 tables on different id

SQL inner join query: Select r.RoleName From webpages_Roles r Inner Join webpages_GroupInRoles gr ON r.RoleID = gr.RoleId Inner Join webpages_UsersInGroup ug ON gr.GroupID = ug.GroupID Where ug.UserID = 1 I…
0
votes
1 answer

Custom LINQ extension for make join

Let's say I need create custom expression to make some manipulation with IQueryable and IQueryable. Regretfully I do not have idea how to implement this. This is my try: public static IQueryable JoinQueries(this IQueryable query,…
andrey.shedko
  • 3,128
  • 10
  • 61
  • 121
0
votes
0 answers

How to write linq function query

IRun runstub = c => One(1) == true; exec(runstub); What's wrong here? It gives an exception "Cannot convert lambda expression to type 'IRun' because it is not a delegate type" public static IEnumerable exec(T t) where T :…
Beta
  • 87
  • 7
0
votes
1 answer

Can't understand how to code Func, T3>

I have this method: public static IQueryable Test(this string text, Func, int> func) Here char is the character to find in text, bool determines whether the character is found and int returns the index of the character in the…
Beta
  • 87
  • 7
-1
votes
2 answers

How can I get a list of items that is part of an object?

I have something like this: class SomeClass { public int Id {get;set} public int someProperty1 {get;set;} public int someProperty2 {get;set;} public string someProperty3 {get;set;} public List SomeObjects…
ojek
  • 9,680
  • 21
  • 71
  • 110
-2
votes
1 answer

C# Merge lists together

I want to merge the fields of songDetails and savedSongs together. How do I do this? I have heard of .Zip() but I am unsure on how to use it. [HttpPost] public ActionResult Upload(IEnumerable songDetails) { …
sitBy
  • 271
  • 5
  • 19
-2
votes
1 answer

How to write linq extension method for all types?

I have this method that I want to write: public static IQueryable CutTo(this IQueryable source, Func func) { int index = func(); // here I can write something for all types or switch all // the types and…
Beta
  • 87
  • 7
1
2