LINQ to SQL is a component of .NET Framework version 3.5 that provides a run-time infrastructure for managing relational data as objects.
0
votes
0answers
7 views
Fast native SQL, but slow LINQ-to-SQL
See the following simple queries:
var stringList = db.A.Where(a => IsTrue == true).Select(a => a.string);
foreach string in stringList:
var c1 = db.ExecuteQuery<int>("SELECT COUNT(*) ...
-2
votes
0answers
8 views
Linq to Sql on Multiple select and groupjoin
I've got the below SQL query working.I need help on how to handle it in linq to sql.
select * from (
select sharerepo.Status status,Users.UserName,Users.UserId from class
join section on ...
1
vote
3answers
43 views
Cannot implicitly convert type 'System.Linq.IQueryable<Database.Table>' to 'bool'
Hello I am getting the error
Cannot implicitly convert type 'System.Linq.IQueryable<Database.Table>' to 'bool'
From this piece of code
foreach (var file in files)
{
if ...
2
votes
3answers
52 views
How can i use a where clause within a select statement in linq. (ie. on a property.)
I have this linq query:
var sku = (from a in con.MagentoStockBalances
join b in con.MFGParts on a.SKU equals b.mfgPartKey
join c in con.DCInventory_Currents on b.mfgPartKey ...
3
votes
2answers
49 views
When selected into an object; does Linq To SQL still perform the logic in a SQL Query?
Let's say I have the following simplified Linq query which will be run against the database using LinqToSQL:
public IEnumerable<MembershipDto> GetAllUserMemberships()
{
return (from m in ...
0
votes
1answer
62 views
How to make cumulative search with LINQ
If i want to search by req_ser ,req_year .. ,so on fields
I do the following :
if (obj.RequestSerial != 0)
{
if (condition != "")
...
0
votes
0answers
40 views
Update DataGrid with LINQ
I have a small problem with at Datagrid that is connected to my LINQ.
I have this function to add to the database
public void Save(string fileName, DateTime collectionTime)
{
try
...
0
votes
0answers
7 views
Linq to SQL - Turn off UpdateCheck in code
I am wanting to turn off the UpdateCheck functionality for all members (except their primary keys). Now I was following the example below as guidance, however my MetaDataMembers of the table are still ...
1
vote
1answer
25 views
LINQ to SQL datacontext passing data to a grid in view
just trying to fathom out LINQ to SQL and datacontext class.
I am learning MVC coding and have a database with some test data.
I have created my datacontext and have been able to get this far in the ...
3
votes
3answers
67 views
Multiple keyword database search using c# (linq to sql)
I am trying to build a search that accepts multiple keywords (space delimited or comma, that is not the issue).
I currently have this
public IQueryable<Post> Search(string criteria, int x)
...
0
votes
2answers
85 views
Multi Threading with LINQ to SQL
I am writing a WinForms application. I am pulling data from my database, performing some actions on that data set and then plan to save it back to the database. I am using LINQ to SQL to perform the ...
0
votes
0answers
26 views
Execute Store Procedure from Linq to Sql WCF
I have a stored procedure for getting user details. In that there is one input parameter i.e. @UserName. Here is my stored procedure
USE [Test]
GO
/****** Object: StoredProcedure ...
0
votes
1answer
27 views
Combining Querys
I am using Linq to Sql to get two lists than take Union with another list. They are working fine. But I am wondering if it can be done in one Query or two instead of three that I have.
Querys are
...
0
votes
2answers
38 views
Taking union of two lists based on column
I am taking a union of two lists using Linq to Sql. Using List1 and List2:
var tr = List1.Union(List2).ToList();
Union works fine, but the problem is it is checking each column and removes some of ...
1
vote
1answer
25 views
Abstract DataContext in DLL
I have a database schema and I'm attempting to create a "base" library around it. I have several other applications that use the same base tables and I would like to commonize the code.
So I guess I ...
1
vote
3answers
47 views
Returning IQueryable from within a using block. Need better design
I have created a PhoneBook style application; on my phonebook object I have a local member _site which is used as a filter, since there are approximately 1000 phone numbers, split across 12 sites ...
-1
votes
1answer
19 views
Update combobox after inserting / deleting record Linq to Sql [closed]
I inserted a new record using Linq to Sql SubmitChanges() method.
How can I update the combobox so it will show the new record as one of the items?
Same question regarding deleting a record.
1
vote
1answer
37 views
Could not find an implementation of the query pattern - linq error
Having trouble with my linq query in my model of MVC. I have an edmx which is composed of ObjectSet and EntityObject. this is where im getting the error "from c in CanaClie0012". when i go to ...
0
votes
2answers
26 views
convert select query to linq on sql server 2008
I have two tables: Album(AlbumId, AlbumName) and Photo(PhotoId, PhotoName, AlbumId)
I have :
select top 1 Photo.PhotoId
from Photo
where Album.AlbumId=Photo.AlbumId
order by NEWID()
This is ...
-1
votes
0answers
8 views
convert sql to linq using on MVC4
I have sql bellow:
select Project.ProjectId,Project.ProjectName,Project.PM,Project.Introduction,
Photo.PhotoName,Photo.[Path]
from Project inner join Album
on Project.AlbumId=Album.AlbumId
inner join ...
0
votes
1answer
28 views
LINQ right outer join with multiple conditions in join
I'm trying to convert the following SQL to LINQ:
select * from ClientCommands as cc
join ClientCommandTypes as cct on cc.ClientCommandTypeID = cct.ClientCommandTypeID
right outer join ...
0
votes
0answers
20 views
EntityFunctions.TruncateTime and unit tests 2?
I am running into the same issue as this previous poster, see : EntityFunctions.TruncateTime and unit tests
The difference is that I have 2 objects (tables) that I link in my query on an Id. One of ...
1
vote
1answer
49 views
Linq to sql query: how to prevent duplication of code
My problem
I'm very new to Linq and I have to difficulties using it. I have written functional queries but I was forced to duplicate some code in every single query. The first part for the queries ...
-1
votes
4answers
80 views
Upload File and Save to Database
I am trying to upload a file from disk and then insert the file into a varbinary db column.
I can't seem to figure out how to insert the binary file.
I am using C# and Linq to Sql in a WPF ...
0
votes
1answer
6 views
Is Linq to Sql DeleteOnSubmit threadsafe?
Assuming the decision to delete is independent and threadsafe, is it threadsafe to call DeleteOnSubmit in parallel?
All entities will be added to the delete in parallel, then the change will be ...
0
votes
2answers
59 views
Can you query recently added objects without calling SubmitChanges?
Without getting into the details of my application I am curious if this is even possible in linq-to-sql or not.
Can I write a LINQ statement to look at both the records in the database and records ...
0
votes
1answer
41 views
Is there something like .take for varchar?
I have a table that has addresses in it and I need to retrieve at least 13 of them in order after they are sorted by street name and street number. Both fields are stored as nvarchar so .take will ...
0
votes
2answers
27 views
linq to sql Object Reference not set to an object
I have this query in Linq to Sql
decimal Rewards = db.User.FirstOrDefault(x => x.FFUserID == UserID).TotalCommission;
This query didn't find a record matching the userID , so obviously that's ...
6
votes
2answers
58 views
Why is Convert.ToDecimal returning different values
I was hoping someone might help me understand why Convert.ToDecimal when used within linq is rounding a decimal and when used outside, it does not
Given the following DB:
CREATE TABLE ...
0
votes
2answers
51 views
LINQ To SQL Include existing object in insert
In this method, I am inserting a new item (Room) into the database. That process functions as expected.
But, in addition to that, each time I add a room, I want to add a piece of furniture as the ...
0
votes
1answer
21 views
LINQ-SQL keep requiring money column to be of type Single, even though it already is
The error I get is this:
The 'SalesValue' property on 'ItemSale' could not be set to a 'Decimal' value.
You must set this property to a non-null value of type 'Single'.
But I already did:
...
0
votes
1answer
19 views
Linq to Sql Connectivity
I am trying to fire a simple query of Linq
var user = (from u in Users
where u.Username == 'ABC'
&& u.Password == 'ABC'
...
0
votes
1answer
34 views
Linq To Sql Insert For This Statement
Does this insert sql statement have a equivalent using linq to sql or how to write the insert in linq to sql?
INSERT INTO Table(FileId, FileTitle, Action, FileAsBinary, UploadDate)
Values(NEWID(), ...
1
vote
1answer
26 views
selection of last-child in xml document
I've started exploring c# and am looking at handling xml.
var doc = XDocument.parse("some.xml");
XElement root = doc.Element("book");
root.Add(new XElement("page"));
XElement lastPost = ...
1
vote
1answer
59 views
The X property on Y could not be set to a 'Decimal' value. You must set this property to a non-null value of type 'Single'
So I have this fairly compelx LINQ query:
// This query will get the top 10 items sold.
IEnumerable<IGrouping<Item, ItemSale>> results = (
from x in ...
2
votes
3answers
39 views
Does user authentification prevent concurrency issues?
I am using LINQ to SQL in order to read/write a database on a server. Right now only the creator of an db-entry can change the according information.
Is it guaranteed that thereby no concurrency ...
0
votes
0answers
40 views
Is something like this possible in one Linq statement? [duplicate]
I want to replicate the following SQL query in LINQ:
SELECT * FROM TABLEA
WHERE TABLEA.LOOKUPID NOT IN
(SELECT TABLEB.SOME_VALUE FROM TABLEB)
I know I can do this using two linq queries, but I ...
0
votes
1answer
47 views
Create service layer with mocked data from LINQ DataContext
I'm using LINQ-to-SQL with ASP.NET MVC 4, and as of this moment I have a repository layer which contacts a real database. This is not very good when I want to unit test.
Also there should never be a ...
1
vote
1answer
46 views
Should I create a view or another table?
Firstly, as a disclaimer, I'm learning a little about SQL/LINQ indirectly through C#. I'm very green in both really. I've quickly grown tired of using sample databases full of data and doing queries ...
0
votes
1answer
24 views
Linq to Sql, group by 2 property and substring
I have an initial query that I want to modify to increase granularity in my results. But Visual Studio tells me my query isn't valid and I can't understand why. Basically I want to group my data ...
0
votes
2answers
25 views
Merging DataTables with Condition
I would like to merge DataTables in a list using sum or average depending on conditions. For example:
private DataTable getData(List<DataTable> datas, string[] KeyColumnNames, string valueCol)
...
1
vote
1answer
69 views
SubQuery and Group by in linq
This query was written in the our system some time ago but the performance of this query is getting poor with a little increase in data. My investigation shows (CodeCount) where query firing another ...
-8
votes
0answers
49 views
Error Cannot Insert Value Null into Column [closed]
I have stored procedure in SQL server 2008 and when I execute it from application using Linq To SQL DBContext display error cannot insert null into column .... but when execute it from SQL with same ...
2
votes
1answer
83 views
How do I optionally reverse the sorting order in Linq-to-Sql?
I have the following code:
IQueryable<Guid> GetOrdered(IQueryable<Guid> ids)
{
return from id in ids join storedId in storedIds on id equals storedId.Id
orderby ...
-1
votes
2answers
34 views
Adding new record in a related table in database
I want to add new records to an related table. I got three tables:
I want to add new technical_skill_value to that table.
This is my code right now:
using (var db = new ...
1
vote
2answers
46 views
Issue with ViewModel returning null values to View
Most of the values in my viewmodel are being returned successfully, but after I updated my model classes, two of those values (which are tied to other tables in the database) return null values, even ...
0
votes
1answer
37 views
The principal end of this association must be explicitly configured using either the relationship fluent API or data annotations
I have two SQL tables:
class DiaryItem
{
private System.Guid Id;
private string Name;
}
class DiaryActivityItem
{
private System.Guid Id;
...
1
vote
1answer
21 views
How Force Linq to Sql classes to use connection string from file
I want to put my connection string in a file like .udl, to change connection string from outside project, because i want to put my db to a server.
I use LINQ to SQL Classes and typed dataset, i want ...
2
votes
2answers
75 views
Linq to Sql .Except not working if null in C#
I have a simple query.
It checks for a list of rooms - prebookedRooms
It then checks for another list of rooms, but uses the .Except operator, to remove any prebookedRooms from the subsequent list:
...
0
votes
0answers
30 views
How to get the result of a CLR stored procedure via LINQ-to-SQL
My database has a CLR stored procedure like this:
[SqlProcedure]
public static void GetRecords(DateTime day) {
using (SqlConnection conn = new SqlConnection("Context connection=true")) {
...