I'm using Linq to SQL and trying to filter data using DataOptions and AssociateWith.
I have a table called Products that has a primary key called Id and a flag called IsDeleted with sql-datatype bit.
When I use the following code I get "Subquery is not supported on 'IsDeleted' of type 'Entities.Product'" exception on AssociateWith meth...
I have an entity that has a collection of associated entities in an EntitySet. Ultimately, I'm trying to report on some changes that have been made to this entity. I will most likely use the GetModifiedMembers() method to do this, and I'm guessing I can just do the same with each entity in the EntitySet, but I'm not sure how to tell if t...
Is there anyway simple ways to add a property to Linq to Sql generated entity to reference its DataContext?
For example:
var myContext = new DataContext();
var product = context.Products.Where(p => p.Id == productId).SingleOrDefault();
and product entity has a property called "Context" (product.Context) that has a reference to the my...
Hello,
I have multiple tables with an "id" component. I'd like to use LINQ to get an item from one of these tables with the correct LINQ-To-SQL type, but only using one CompiledQuery.
Here's an example that works currently. Say the object type defined in the DBML is "myitem" and its table is "myitems".
var getOneItem = CompiledQu...
I've got a new instance of an object in a Linq DBML, but don't know of the test if the a date field is empty.
I have tried:
If d Is Nothing OrElse IsDBNull(d) OrElse d <= Date.MinValue Then
TextValue = "nada"
Else
TextValue = FormatDateTime(d)
End If
But the result is "12:00:00 am"
edit: Changed variable name the d
edit: Pleas...
Just dipping my toes into Linq2sql project after years of rolling my own SQL Server DB access routines.
Before I spend too much time figuring out how to make linq2sql behave like my custom code used to, I want to check to make sure that it isn't already "built" in behavior that I can just use by setting up the relationships right in the...
Hi guys,
I have a collection called dbUsers of type IQueryable
These are pulled from a linqtosql database context i.e.
IQueryable<Data.LinqToSQL.User> dbUsers = DBContext.Users
Calling ToList on this object:
IList<Data.LinqToSQL.User> users = dbUsers.ToList();
Results in an exception:
ExecuteReader requires an open and available...
I get the data from the database like this.
Dim query = From t1 In TBL1 _
Join t2 In TBL2 On t1.ID Equals t2.ID _
Join t3 In TBL3 On t1.ID Equals t3.ID _
Group Join t4 In t1 _
On t1.ID Equals t4.ID _
Into t4_Grp = Group _
Select t1, t2, t3, t4_Gr...
What major features are missing from Linq-to-Sql?
Compatibility with other major SQL Database Engines (MySQL etc)
Mapping Many-to-Many relationships
Any others?
I have already developed a major project with Linq-to-Sql at it's DAL Heart. i hadn't developed using a relational data mapper before, so it was a learning curve coming from ...
I have a truckload of xsd with plain SQL queries. I want to migrate to LINQ.
Is there a automated way to generate LINQ equivalents from SQL statements?
...
Hi guys
I am wondering what's your opinion about this. I have used L2SQL in my last project, and its a great OR mapping system. I have never used EF yet, however I have read that the Microsoft team seem to give it more importance than the L2SQL.
What's your opinion?
(edit: multiple duplicates - see comments, most notably: Entity Fra...
My situation is roughly similar to this guy except that I don't need change notifications right now
I have a WPF App displaying a hierarchy. The children for each node are retrieved using a LinqToSql query. The app works perfectly when there is one thread.
Now I'd like to make things a bit faster.. by loading children asynchronously. F...
If all my sql server database access is done thru stored procedures, and I plan on continuing that practice, is using linq2sql and/or the entity framework for future projects an unnecessary layer of complexity that doesn't add much value?
Related question: is Microsoft trying to steer developers away from relying on stored procs for dat...
I would like to write this as a user defined function:
private double Score(Story s){
DateTime now = DateTime.Now;
TimeSpan elapsed = now.Subtract(s.PostedOn);
double daysAgo = elapsed.TotalDays;
return s.Votes.Count + s.Comments....
I have 2 related database tables which in simplified form look like this
Product(
product_id,
name
)
ProductSpecs(
spec_id,
product_id,
name,
value
)
Foreign key is set via product_id field and ProductSpecs table has a unique constraint on (product_id, name) pair.
Now in my ASP.NET MVC application when user edits product...
Hi, i'm using LINQ To SQL to perform an insert via db.table.InsertOnSubmit(). I'm wondering if there is a way to reproduce the T-SQL version of the 'where not exists (select etc etc) begin insert into etc etc end' as one single query? Thanks, Martin
...
So here is the original query
SELECT SUM(PickQty), SUM(ReqQty), AssignmentID, StopID
FROM PickRequest
GROUP BY AssignmentID, StopID
in LINQ
from a in dbReqs
group a by new { a.AssignmentID, a.StopID }
into pr
select new
{
Assignment = pr.Key,
StopID = pr.Select(s=> s.StopID),
PickQty = pr.Sum(p=> p.PickedQty),
Count = pr.Sum(c => c.Re...
I'd like to extend the AuthorizeAttribute in ASP.NET MVC so that it supports the concept of a user's authorization being based on their role membership OR "ownership" of the data in question. I'm using LINQ2SQL for data access. There is a similar question at http://stackoverflow.com/questions/390930/asp-net-mvc-authorization-using-roles....
I'm working on better understanding Linq-to-SQL before using on a real project, so I'm playing with it on a little side project. I've a table that I'm trying to update via DataContext.SubmitChanges() and it's failing due to primary key constraints.
I have no control over the table itself (I can't add an actual ID column), so instead ...
I have two tables, DH_MASTER and DH_ALIAS. DH_MASTER contains information about a person, including their name. DH_ALIAS contains AKA records about the person. The tables are linked by the Operator field which is a primary key in DH_MASTER.
The users want to search by the name stored in DH_MASTER as well as search through all of thei...