linq Questions

3

Solved

I have a Collection, I'm trying to use the Distinct method to remove duplicates. public static Collection<MediaInfo> imagePlaylist imagePlaylist = imagePlaylist.Distinct(new API.MediaInfoCo...
Gwen asked 30/12, 2011 at 5:15

4

I have a data call in a Linq to Entities powered data access layer that is designed to make paged calls. In doing so, I need to select a subset of the data, say 50 rows, but also get the count of ...
Mosenthal asked 23/3, 2015 at 18:54

7

Solved

I'd like to order my list by a string converted into an int: var orderedListOfRfidTags = uow.RfidTags.OrderBy(t => Convert.ToInt32(t.Number)).ToList(); but get: The method 'ToInt32' is not su...
Marianomaribel asked 12/5, 2011 at 21:52

4

Solved

I have a list of checkbox elements in a html page, all selectable and with distinct IDs, and its IDs are send by HTTP POST to my API. For security, I need to check if any of the sent IDs is invalid...
Unborn asked 7/5, 2018 at 22:6

6

Solved

I have a medication table that I'm looking for certain drug names, but I need to search for multiple names. Here is where I currently am with it. string[] names = new string[2]; names[0] = "apixab...
Entourage asked 5/3, 2013 at 22:48

3

Solved

I want to populate a drop down with the public properties of a particular object, which I have done fine. But now when the user selects the value from the dropdown, I want it to group the DB table ...
Aquileia asked 23/10, 2013 at 11:41

7

Solved

I've got a User table with a bitmask that contains the user's roles. The linq query below returns all the users whose roles include 1, 4 or 16. var users = from u in dc.Users where ((u.UserRoles...
Stomachic asked 7/10, 2008 at 21:3

6

Solved

I want to search my db with different keys. According to the input, there may be 1 key to 10 keys. Is there a way to add OR/AND clauses to my Linq query dynamically? keys[k] // I have my keys in ...
Hyperextension asked 14/1, 2013 at 14:10

12

Solved

I simplified the code a little while trying to debug: [HttpPost] public ActionResult Register(User model) { DateTime bla = new DateTime(2012, 12, 12); try { User user = new User { gid = 1,...
Fran asked 30/5, 2012 at 14:49

4

Solved

I would like to know to to write most efficient LINQ (EDIT: to Entities) query with a list as a condition. Here is the thing. Lets say we have the following data structure: public class Recipe ...
Homunculus asked 13/1, 2010 at 8:5

4

Solved

I have a LINQ expression that is working fine on the production database but throws an error on the SQLite in-memory database of the test context: The LINQ expression (EntityShaperExpression: Enti...
Inland asked 3/3, 2020 at 9:1

5

this is my first question and sorry about my weak language. I've got a table like this model; public class Menu { [Key] public int ID {get;set;} public int ParentID {get;set;} public string...

2

Solved

When creating new objects in a LINQ statement, for example: var list = new List<string>() { "a", "b", "c" }; var created = from i in list select new A(); With class A looking like this: c...
Lussier asked 20/9, 2013 at 12:45

1

In an answer to my another question I was told to use QueryExtensions to achieve async computations with F# and Entity Framework, and I'm using that advice successfully. For example, I have the fo...
Rame asked 4/10, 2015 at 10:56

6

Solved

I'm trying to get data from a LocalDb into my MVC Controller. I tried this: UsersContext db = new UsersContext(); var users = db.UserProfiles.Where(u => u.UserId == WebSecurity.CurrentUserId) ...
Shadowgraph asked 17/12, 2013 at 15:14

12

I know a typical way is like this: IQueryable query = from staff in dataContext.Staffs; if(name1 != null) { query = from staff in query where (staff.name == name1); } However, from a program we...
Underage asked 26/4, 2011 at 8:30

3

Solved

I have this xml <config> <audio first="true" second="false" third="true" /> </config> I want my code to able to do something like this if (xdoc.getAttr("first")=="true") Con...
Thorrlow asked 13/12, 2010 at 14:39

2

Solved

It's common in C# to modify objects in private methods as they are commonly reference-types instead of value types, for example: public void Main() { var person = new Person(); SetPersonsName(p...
Looseleaf asked 20/10, 2014 at 10:14

4

Solved

i have to find out whether or not two collections have any intersection, the way that i did that is using LINQ's "Join" to get the Intersection of the two collections and then i use "Any". But i wo...
Bougainville asked 16/5, 2012 at 22:5

5

Solved

I am getting the following exception: The nested query is not supported. Operation1='Case' Operation2='Collect' with this query var Games = context.Games.Select(a => new GameModel { Membe...
Laevorotatory asked 1/3, 2013 at 22:34

4

Solved

Linq newbie here, struggling with my first GroupBy query. I have a list of objects of type KeywordInstance which represents a keyword, and the ID of the database record to which the keyword was app...
Reach asked 6/11, 2013 at 13:10

8

Solved

I have this sql statement SELECT userID from users WHERE (name='name1' AND username='username1') OR (name='name2' AND username='username2') OR (name='name3' AND username='username3') OR .............
Amalberga asked 8/4, 2011 at 12:55

7

Solved

I am looking to perform a query on an example list of objects Date Username 01/01/2011 james 01/01/2011 jamie 01/01/2011 alex 01/01/2011 james 02/01/2011 matt 02/01/2011 jamie 02/01/2011 alex 02/...
Stoma asked 3/2, 2011 at 9:42

8

Solved

I have a fairly basic question: How can I check if a given value is contained in a list of enum values? For example, I have this enum: public enum UserStatus { Unverified, Active, Removed, Su...
Spiky asked 16/3, 2011 at 3:4

6

Solved

I instantiated a context and want to write a simple query: var result = db.Set.Where(x => x.Id == num).Select(whatever); and I can't get rid of the red squiggly under Where complaining about ...
Skiascope asked 8/11, 2013 at 21:59

© 2022 - 2025 — McMap. All rights reserved.