I have two very similar methods:
public IQueryable<User> Find(Func<User, bool> exp)
{
return db.Users.Where(exp);
}
public IQueryable<User> All()
{
return db.Users.Where(x => !x.deleted);
}
The top one, will not compile, saying it returns IEnumerable rather than IQueryable.
Why is this?
Also, I am aware I can add "AsQueryab...
Is it possible to get LINQ to SQL to delete a record using the PK, without loading the record first? Similar to NHibernate's proxy object functionality?
...
I am using a lamda expression to filter a query.
Basically, I have lines that are composed of segments and these segments are marked as deleted, inserted or null.
What I want returned are segments that have been marked as deleted but whose any sibling IS NOT marked as deleted. As an example,
Line: "Soylent Green is people!" Broken ...
In general, is one faster than the other, assuming 1 record is being returned?
Are there benefits to using one over the other?
Just as an example:
DataContext.TableBlah.FirstOrDefault(_blah => _blah.id == 1);
or
var test = (from blah in TableBlah
where blah.id == 1
select blah)
...
In SQLServer 2008 stored procedures, SUBSTRING can be used to return only part of a varbinary(MAX) column at a time from a query.
Is a similar feature available when using LINQ To SQL via C# directly in the code?
EDIT: I mean so that only a set number of bytes are loaded in code from the database and not the entire blob each time only...
Does anyone know (ideally, with a reference), whether the VS2010 release of LinqToSQL or EntityFramework v4 will support queries over the SQL 2008 spatial data types?
...
I am trying to achieve the following using the Datalist and Linq to Sql:
Paged Datalist
Efficient paging i.e if there are 3000 records only retrieve the records needed for the current page.
Have the page number displayed in the querystring to allow pages to be cached.
However, when I look at the sql which is outputted it is doing mul...
If LINQ-to-SQL overcomes the object-relational impedance mismatch of a .NET application talking to a SQL Server database...
If I want to build a .NET MVC UI, where my model queries a Documentum CMS database...
Is there a LINQ to DQL (Documentum Query Language) library ? ...
... that will help me overcome the object-relational impedan...
Hi there,
Can anyone help?
I have a created a relationship between my Reservation(prim key) and Insurance(for key) tables and imported into linq2sql and checked my automatically created c# files and sure enough i have reservation.MyFieldNames etc etc PLUS reservation.Insurance which is my relationship but reservation.Insurance i can't ...
I am working on a repository pattern where the API look as follows:
var visitor = repository.Find(x => x.EmailAddress == credentials.EmailAddress &&
x.Password == credentials.Password);
where visitor is a domain object and x represents this domain object. The method signature of the Find method on the re...
Hey folks,
I was just trying out working on a WPF app along with Linq To Sql. It seems that the data in my sql server express database is being erased as I close my application. How can I persist these data updates that I do in my application. Here is my connection string, I am sure that needs to be changed, the mdf file is within a fol...
Hi there,
I have been using automapper pretty successfully lately but i have come across a small problem for mapping the Dest to a variable not a available in the Src.... An example explains it better.. basically i am mapping from dest to src as per instructions .. all working well but i need to now map a destination to a variable named...
I'm not super familiar with Linq to SQL yet but something that strikes me is that this:
var articles =
(from a in DB.Articles
where
a.ArticleId == ArticleId.Question &&
a.DeletedAt == null &&
a.Votes >= minVotes
orderby a.UpdatedAt descending
select a).
Take(maxarticles);
gets translated to this:
string query =
"...
Hi
I am very new to linq to sql and I am not sure how to actually delete a record.
So I been looking at this tutorial
http://weblogs.asp.net/scottgu/archive/2007/05/19/using-linq-to-sql-part-1.aspx
So for Update they have
NorthwindDataContext db = new NorthwindDataContext();
Product product = db.Products.Single(p => p.ProductName =...
Hey all,
I'm working on an application at the moment in ASP.NET MVC which has a number of look-up tables, all of the form
LookUp {
Id
Text
}
As you can see, this just maps the Id to a textual value. These are used for things such as Colours. I now have a number of these, currently 6 and probably soon to be more.
I'm trying to pu...
I have a LINQ to SQL datacontext that is wrapped in a static class so it can be accessed from anywhere in our web application.
Our project is split into two different parts: 1 - the business layer (a class library) and 2 - the front end web forms.
When I access the datacontext from the web form part of the project I can use all of the e...
I have two tables, A and B and a simple table, X, that maintains a relationship between the two. X contains AID and BID as its primary key.
I'm using Linq-to-Sql to insert a relationship like:
public void InsertRelationship(int y, int z) {
DataContext.X.InsertOnSubmit(new x { AID = y; BID = z });
}
The problem is that two calls to ...
I have a Linq-To-SQL object obj of type MyClass that I have loaded via my data context.
Now I want to force that object to save, even if no fields have actually changed, so that the save action can set off some triggers behind the scenes.
What's the easiest way of making my data context think that obj is dirty, so that a call to Submit...
Hi!
I'm currently using Linq to sql as my OR-mapper. My problem is that i can't come up with a way to do crud-operations on a many-to-many context.
The read part is no problem. I just create a partial class and expose a property that reads all entries using my relation table.
What is the best way to add Create, Update and Delete funct...
Hi all,
I'm using LINQ to SQL and DataGridViews to create an editable user interface of a database.
My problem is that I have to translate the column names when fetching the results from the database, because while all names in the database are in English (the only language supported by the visual studio class designer) I have to displa...