Use this tag for code reviews of or involving Linq to SQL classes, mappings and associations, or for code reviews of or involving querying a System.Data.Linq.DataContext object with Linq statements.
7
votes
1answer
104 views
GET with paging, sorting and filtering
I have a GET method that handles paging, filtering, and sorting. Development has been fairly rapid and I'm not completely sold on some of the implementation. A few assumptions have to be made for this ...
2
votes
1answer
33 views
Need to get rid of .Any() to calculate the .Sum() in Linq-to-Sql
I have the following code where I need to execute 2 linq-to-sql statement. If I do not have the Any() in the if statement, then ...
0
votes
0answers
47 views
LINQ SQL query to display the status of tracked computers
This is my existing LINQ SQL. At the moment it works, however the using the coalescing operator for null results on the "let" clauses make me feel like I'm violating some sort of unwritten rule. Is ...
3
votes
1answer
191 views
Returning an IEnumerable using Linq-to-SQL which is then bound to a GridView
This function works, but it's really really slow and the generated SQL is gargantuan and horrible to look at. It's also very expensive to run when it shouldn't be.
...
1
vote
1answer
57 views
Eager Loading Deeply into a Model with a Collection Property Whose Type is Inherited
Visual Studio generated this great route for me, where I can load an entity:
...
2
votes
1answer
195 views
Simplifying a LINQ expression that finds the largest date smaller than another date
I have a LINQ 2 SQL query that needs to run a subquery in the where clause. The subquery just returns the largest date (from a date column) that is less than or equal to another date (an input to the ...
7
votes
3answers
199 views
Fetching a set of event IDs from a database based on a set of company IDs
The following code fetches a set of company IDs from a database if there are any events associated with a company that has a missing property. Because the set of company IDs is embedded into the SQL ...
3
votes
2answers
1k views
Linq-to-Sql Contains an int? inside a list of int
Curious if there is a better way to write a repository method that receives argument List<int> and checks if the database ...
3
votes
4answers
205 views
Website news message edit panel
The explanation
I'm making a website for a hypothetical theatre to get a better feel of MVC web-applications in ASP.net. The idea is that there are newsmessages that are displayed on the homepage, ...
4
votes
1answer
135 views
Inserting customer care database analysis detail records
I have written this linq-to-sql query to insert a bunch of customer care database analysis detail records:
...
2
votes
2answers
316 views
Delayed Include rules for EntityTypeConfiguration using LINQ expressions
The aim of this class is to set rules for including navigational properties on Configuration level and then apply where needed in the code.
I've decided to store expressions in the list for different ...
1
vote
1answer
1k views
Converting table data into nested JSON
I'm new to C# (coming from a JavaScript background) and it seems like this code could be greatly improved.
This SQL query:
...
2
votes
2answers
501 views
Checking for user permissions
The idea here is we have Roles, Permissions, and a table called PermissionRoles that connect the two. So a Permissions can be in many Roles, and many Permissions can have the same Role. So what the ...
3
votes
2answers
366 views
Linq-to-SQL DAL on a Windows Forms project
I just started out a new job as a C# programmer on .NET 3.5. My manager gives me total independence on how I build my modules, which is generally a good thing, but there are minuses too. Having too ...
3
votes
1answer
197 views
Extension method to do Linq Lookups
Does this extension method contain unnecessary work? - Thanks for reviewing
Scenario - A series of tables are Key-Value pairs (Int "Id" / nvarChar "Title"). This extension method "dots-off" any ...
0
votes
1answer
308 views
Simplify IQueryable Linq to SQL query
Below I present to you an IQueryable LINQ to SQL query (used with NHibernate).
I have tried to simplify this query but I could not do it.
I want to run a query for searching information.
Options:
...
3
votes
1answer
272 views
Why is loading images taking so long?
When Page_Load is executed I assign the ImageUrl which is a IHTTPHandler:
...
3
votes
3answers
571 views
Code optimization by constant if-structure iteration removal
Below you will find the specific code that I am attempting to optimize. I have a method previous to called getCount() which, based on similar parameters as below, ...
2
votes
2answers
562 views
Linq C# pulling from table row into input fields
Today is the first time I've used Linq, so I wanted to get a code review on this and make sure I'm going about it correctly.
I'm filling text boxes and dropdown lists from a table row.
...
10
votes
1answer
445 views
Password Manager UI: Populating DataGridView is Painfully Slow
I'm designing a small account/password manager using C# and SQL Server CE. LINQ to SQL is my ORM of choice.
Here's the data model representing how the SQL Server CE database is set up:
And here's my ...
6
votes
1answer
8k views
A generic way to use LINQ to Entity with types and operations unknown until run time
A question was asked here about reflection and LINQ to entity. I'm trying to modify the code that was presented to fit my needs.
Here's what I am trying to accomplish: I'm writing back-end support ...
7
votes
1answer
1k views
Redundant DataContext ? - LINQ to SQL
This seems like a pretty basic question, so bear with me...Say I have two (or many) methods in the same class that need a LINQ to SQL DataContext. Additionally, I am needing the DataContext in other ...
2
votes
3answers
164 views
How to make my code faster and easier?
This is my .cs part code where I am calling storeprocedure in LINQ to SQL:
...
7
votes
1answer
153 views
Does this unusual data access pattern create any problems?
The background
Two beginners without access to an experienced mentor write an ASP .NET MVC application, mostly simple CRUD, using Linq to SQL for the data access layer. Beginner number 1 writes the ...
3
votes
1answer
317 views
LINQ statement to aggregate data
Teachers can raise 'dramas' which are when students forget equipment, don't do homework or are flagged for concern. Each drama for each student is stored as a separate record.
I seek a list of all ...
7
votes
1answer
340 views
Comparison table for comparing products
I'm attempting to create a comparison table to compare products depending on the add-ons they have. To grab the data and filter it I'm using LINQ To SQL.
Table's Layout (cut short):
...