I have a textbox that allows a user to specify a search string, including wild cards, for example:
Joh*
*Johnson
*mit*
*ack*on
Before using LINQ to Entities, I had a stored procedure which took that string as parameter and did:
SELECT * FROM Table WHERE Name LIKE @searchTerm
And then I would just do a String.Replace('*', '%') befor...
I have a fairly complex LINQ to Entities query I'd like to try compiling because it's a bit slower than I'd like.
I build it in a series of steps though. Here's a simple example:
public static List<Employee> GetEmployees(EntityContext ctx, bool showTerminated)
{
var q = ctx.Employees;
if(showTerminated==false)
{
q ...
I have a hard time telling what operations in linq cause a SQL command to be issued to the database.
I know calling ToList() or iterating w/ foreach will cause the query to run but do Select and GroupBy cause the code to execute on the database?
...
I am getting the above mentioned error with this expression:
var aggregate = from t in entities.TraceLines
join m in entities.MethodNames.Where("it.Name LIKE @searchTerm", new ObjectParameter("searchTerm", searchTerm)) on t.MethodHash equals m.MethodHash
where (t.CallTypeId & (int)types) == t.CallTypeId && t.UserSessionProcessId...
I do have List<ColumnDiff> columnDiffList
of
public class ColumnDiff
{
public string columnName;
public string leftValue;
public string rightValue;
}
I need to determine whether there are elements where columnName either "A", "B" , "C"
It is not essential to extract a subList.
In SQL terms
colum...
In a previous post there was mentioned using an overload of the Select method to reference an Index value. This would be exactly what I need to answer this question
However, when I try to use this overload as below, I get a NotSupportedException
DbObjects.OrderBy (o => o.CreatedOn ).Select((o,i) => new {entity = o, rownumber = i})
I...
I have one specific view created in my DB(joins about 5-6 tables with a left join).This view is added to my edmx (entity framework 1.0) . Recently I noticed that one of the column records obtained using the edmx (linq to entities and then ToList()) got duplicated multiple times though in the database view they were different
Column-N (E...
I have read plenty of blog posts and have yet to find a clear and simple example of how to perform a LEFT OUTER JOIN between two tables. The Wikipedia article on joins Join (SQL) provides this simple model:
CREATE TABLE `employee` (
`LastName` varchar(25),
`DepartmentID` int(4),
UNIQUE KEY `LastName` (`LastName`)
);
CREATE TABLE `depa...
I've just recently started using LINQ on a daily basis. I've read quite a lot about L2E queries should be compiled to improve performance using the following:
CompiledQuery.Compile(query);
Using LINQ-To-Entities 4.0 I ran a query 10 times uncompiled and then compiled and yielded the following results in seconds:
// Sample Query
from ...
What is the best way to handle linq to entity exceptions? Can I use try and catch block or is there better way?
...
I am trying to optimize my database now using Database Engine Tuning Advisor, and the problem I am facing is that my SQL Profiler trace shows tons of queries performed using sp_executesql - and the advisor fails to process those. It seems like these queries come from LINQ-to-Entities I am using, so just curious if there is any way to mak...
I'm using Linq to Entities for some simple database access.
In the automatically generated entities, there's a Class IndexMeta, which refers to a collection of objects of class IndexData.
Although i set the ObjectContext like this:
this.xxxDataEntities.ContextOptions.LazyLoadingEnabled = true;
It seems the DataEntities is still doin...
Is there a way to apply Where clauses on to the Included child tables?
Example:
I have a Customers entity set and and Addresses entity set, and I've appropriately decorated the metadata class with the [Include] attribute. I can easily filter on a property of Customer, such as last name...
public IQueryable<Alphagram> GetCustomersWit...
Looking for a combined INSERT/UPDATE/DELETE statement, MERGE is exactly what I need, but I can't seem to find if LINQ/SQL supports it (from http://www.sqlbook.com/SQL-Server/SQL-MERGE-35.aspx)
-- Merge order items into OrderItems table
MERGE INTO OrderItem As oi
USING @UpdatedItems ui
ON (oi.OrderID = ui.OrderID AND oi.ProductID = ui.Pr...
How to choose that which ORM would be feasible for a web Application? e.g if we are using Linq then why not nhibernate? and Which one is better and why
...
New to L2E, found out that I can't use DefaultIfEmpty() until I get L2E 4 (which will hopefully be happening soon). I found an article regarding left joins via inverse navigation, which seems like a clean method for left joins. That said, the article appears to be incorrect, in that the snippet
from lPnpItem in PnpItems
join lPnpItemVa...
The gist of the problem is that we have an alumni table (one record per person) and also a couple of other tables (one to many) that have degree info and interest info. In a search screen in our app you can search for criteria that spans all three tables (there are actually more fields and tables than shown in the example below but I am...
Hi.
I got a problem with Entity Framework 4.0
I have a hierarchical table Category: Id, Name, ParentCategory_Id, timestamp
The "timestamp" field is marked as "Concurrency Mode" = "Fixed"
And I'm using Self-Tracking Entity "Category" to manage Category entity in my MVC application.
The situation:
I create STE "NewCategory",
set ...
Hi,
Current ASP.Net MVC 2 uses Linq to SQL or Linq to entites? i am using VS 2008.
Cheers
...
I am trying to switch from LINQ2SQL to EF ... I am getting the following error with some code that originally worked with LINQ2SQL and seems to compile correctly:
Csla.DataPortalException:
DataPortal.Fetch failed (LINQ to
Entities does not recognize the method
'MyApp.Logic.UserInfo
FetchUserInfo(MyApp.Data.User)'
method, a...