I'm quite new to linq and struggling to create a query.
I have a 'Customers' table and 'Orders' table, one-to-many relationship.
How do I select those customers, who have oldest order with word 'special' in order description?
If oldest order does not contain this word, customer should not be in the result. If customer does not have ord...
I have a few rows of data pulled into business objects via linq-to-sql from large tables.
Now I want to get a few rows that don't match to test my comparison functions.
Using what I thought would work I get a NotSupportedException:
Local sequence cannot be used in LINQ to SQL implementation of query operators except the Contains() ope...
Why does this work ?
var x = from p in db.People let oCount = p.Orders.Count select p;
And not this ?
var x = from p in db.People let oCount = Count(p) select p;
private int Count(DataContext.Order o)
{
return o.Count;
}
...
Hi,
I have this project where I would like to go from regular ADO.NET code to a more productive, more understandable, leaner and meaner OR/M system. I have the following scenario that currently works but has to work with the OR/M as well:
Orders:
id
stuff
Documents:
id
order_id
path
When I create a new order I attach a document...
I have just started a new project using a Linq to Sql model and I'm implementing our first many to many relationship. I have found this blog that gives great info on how implement this:
http://blogs.msdn.com/mitsu/archive/2008/03/19/how-to-implement-a-many-to-many-relationship-using-linq-to-sql-part-ii-add-remove-support.aspx
When I t...
I am having an issue when trying to submit two inserts at once. The table has a auto increment primary key. The comment objects set up dont have there ID value set so that the database can assign this.
My code works for single inserts if i submit straight away but if i try and do multiple InsertOnSubmit commands then it seems to do noth...
Hi all
I've recently started playing around with the ASP.NET MVC NerdDinner sample, and as part of that you get to play around with Linq to SQL classes. This looks cool, so I decided to break away (perhaps a tad prematurely!) and try and create my own MVC application, but this time modelling my own simple database with Linq to SQL.
The...
A common problem in LINQ2SQL is while the .NET String allows assigning any length to its variable, your database may have a specific max length constraint (like VARCHAR(5)). This will lead to the SQL error message "String or binary data would be truncated.", which is extremely unhelpful since it doesn't tell you which fields is the culpr...
Hi all,
I have a very simple database for which I'm using linq to sql.
I have a datagridview to show the contents of the table. I want the user to be able to filter the rows appearing in the datagridview, if possible without making another query to the database (I'm really low on resources, so the solution has to be as fast as possible)...
Ok, what I'm doing is (I think) rather simple.
I have a LINQ-to-SQL data context set up and one of the tables is Users. In the designer, it shows the class as "User" with the source as "dbo.Users". It's access is Public, and I can reach the database to retrieve and update just fine. The class is set to "Use Runtime" for the I/D/U ope...
Hello all,
I'm using LINQ to SQL and I have a stored procedure which brings back a result set that looks like so:
Type Field1 Field2
5 1 1
6 2 0
21 0 0
I'm hoping to do a few things with this record set:
1) Have 3 groups of results, one that has values in both field1 and field2, one t...
I am currently building a custom Membership Provider for my Asp.net MVC website. I have an existing database with a Users table and I'm using Linq-to-Sql to automatically generates this class for me.
What I would like to do is have this generated User class inherit from the MembershipUser class so I can more easily use it in my custom ...
I've got a painfully simple table that is giving me a "Specified cast is not valid" error when I try to delete one or more rows. The table has two columns, an "id" as the primary key (INT), and a "name" (VARCHAR(20)), which maps to a String in the LINQ to SQL dbml file. Both of these statements produce the error:
dc.DeleteOnSubmit(dc.My...
I am abit curious about dbml.... Should I create one dbml file for one database or separated into different parts e.g. User dbml (only tables relate to users) etc? When I do this I will have abit of problems. Assume the User dbml has a User table and if the Order dbml has a User table as well, this won't be allowed if the entity namespac...
I am new to the MVC/Linq party (coming from Java).
I know that I can use something like the following to get strongly typed access, but what about if I want to use a join in my linq query?
public void IQueryable<Product> GetItems(int CategoryID)
{
...linq query...
}enter code here
...
I'm using Linq from ASP.NET (C#); and I'm trying to add a 'clone record' function. This question - allows copying of a single record from a single table; how can I expand it to include associated records in tables linked through foreign keys?
...
Although this probably isn't best practice, I am trying to clear a series of records from a database table, and then insert a series of records - some of which may have been in the original series, and others which may be new. I'm using linqtosql in C#. Pseudo-code I have to do this is below; it fails with "Cannot add an entity with a ke...
Is it possible to force the LINQ to SQL designer behavior editor to recognize properties on table entities that have not been generated by the designer itself? That is - I want to pass a custom property (defined in my own partial class) as a parameter to a stored procedure.
I've tried manually specifying the parameter name in the XML (w...
Let's say we have two tables with a many-to-many relationship:
public class Left{ /**/ }
public class Right{ /**/ }
public class LeftRight{ /**/ }
is the following sufficient to unhook these records (ignore the possibility of more than one relationship or no relationship defined)?
public void Unhook(Left left, Right right){
var r...
hi.
I have a table whit 2 columns , ID and name .I set 'YES' Identity for ID column .
I want to insert data to table whit LINQ .I want to get only name column from user in my application , and then ID column fill automatic to database and I can't give data that column and fill whitout I give it .
What should I do ?
I write in c# an...