Questions tagged [linq-to-sql]

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.

Filter by
Sorted by
Tagged with
1
vote
2answers
83 views

Exporting test results to PDF tables

I have an asp.net web application and I want to export to a PDF tables in a particular way. Tables will have data of type Test. tests have a type(by type i mean an int to tell them apart) and for ...
0
votes
1answer
57 views

Data validation for to check required fields are mapped

Can I break the below foreach and IF statements into LINQ expression. Also, performance wise which will be better. Please suggest. ...
5
votes
2answers
2k views

Efficiency of a linq query on a nested structure

For a survey website I've written this query to show the survey results, with a percentage for each chosen answer: ...
1
vote
1answer
74 views

Aggregating clients and client types

The code I have put together achieves what I want, but I don't know if it is the right way to go about tackling the problem. I am dealing with 2 tables (CLIENT, CLIENTTYPE) each of which I have an ...
1
vote
1answer
2k views

Selecting employees in certain departments using LINQ

I am trying to select the DepartmentName from Employee Table based on where condition. Is any way to simplify the code? ...
3
votes
1answer
376 views

Search products from database on base of search filters

I am writing a code to search Product database and return result to user. user can select various options like product attributes that varies from product to product, also there may be case like for ...
9
votes
6answers
6k views

LINQ to SQL query filter, with the name match ignoring multiple punctuation characters

I have the following LINQ to SQL query which works fine but looks ugly: ...
3
votes
2answers
353 views

Implementing SOLID Principles - LINQ TO SQL

I have been using Layered Architecture in my web application. Can anyone please advise if my data layer classes (both Linq and booking class) can be improved? I have just started learning about solid ...
8
votes
1answer
2k 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 ...
1
vote
1answer
5k views

Calculating the .Sum() in Linq-to-SQL

I have the following code where I need to execute 2 Linq-to-SQL statements. If I do not have the Any() in the if statement, then ...
1
vote
0answers
60 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
1k 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
326 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: ...
4
votes
1answer
8k 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
223 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 ...
4
votes
2answers
26k 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
370 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
145 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
615 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
10k 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: ...
3
votes
2answers
5k 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
896 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
275 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
715 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
740 views

Why is loading images taking so long?

When Page_Load is executed I assign the ImageUrl which is a IHTTPHandler: ...
3
votes
3answers
579 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
1k 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
551 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 ...
7
votes
2answers
13k 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
2k 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
174 views

How to make my code faster and easier?

This is my .cs part code where I am calling storeprocedure in LINQ to SQL: ...
8
votes
1answer
384 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
360 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
391 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): ...