Hey Everyone,
I've got this really basic table structure:
dbo.tblCategory
dbo.tblQuestion (many to one relationship to tblCategory)
dbo.tblAnswer (many to one relationship to tblQuestion)
So basically, what I'm trying to do is when I load a category, I want to also load all Questions, and all Answers.
Now, I've been able to do this...
Hi,
I am trying to work with silverlight, wcf data services ( on the website code) and Linq-to-Entities. I know that anonymous types don't work on silverlight then I created a known class in order to retrieve some information. (I know the query it is not exactly intelligent, but It is only an example) but It is not working. can somebody...
Hi all,
can someone explain me how to check LINQ generated SQL queries in VWD 2008?
I just have not enough time for figuring it out by myself, so any help is appreciated
Thanks
EDIT:
I am using SQL Server 2008, Entity Framework and ASP.NET MVC
...
I'm using LINQ-to-Entities. Using the following query:
var x = from u in context.Users select new { u.Id, u.Name };
That only selects the Id and Name columns. Great.
I'm trying to make a repository that can be passed that new { u.Id, u.Name} as a parameter to allow the client to pick which columns are used in the SELECT statement.
...
I am developing application using Entity Framework.
When i'm in debugging mode my test values are saved into database when i exit debugging even if i'm not hitting SaveChanges method.
Why is this happening?
I spent 4 hours trying to figure it out, but had no luck....
Even if i have my breakpoint at the start of the action, and i ex...
I have this code,
Data Summary is a class, it is not an entity. I use it for the anonymous type on "select new"
public class DataSummary
{
public DataSummary()
{
}
public int AccountID
{
get; set;
}
public decimal Total
{
get; set;
}
}
then I have this query
DateTime date...
Hello all,
I am running into a strange problem I don't fully understand. The main symptom is that when I double click a link (that points to a controller action) in my MVC application, my database server connection gets blown, and I get the error :
Execution of the command requires an open and available connection. The connection's cur...
I have a query like:
var fooQuery = (from x in edm.stuff where x.col == DesiredVal select x)
'stuff' is a view. When I count the results I get '1'. When I First() or FirstOrDefault() I get null.
var fooCount = fooQuery.Count(); // results in 1
var fooResult = fooQuery.FirstOrDefault(); // results in null
This doesn't make sense t...
I'm trying to reuse part of a query, because it's complex enough that I want to try to avoid code duplication.
It seems that when calling any method inside a query, you end up with:
LINQ to Entities does not recognize
the method {X} method, and
this method cannot be translated into
a store expression
What I would like to do...
I have some methods which perform a standard filter on data from my Entities (using Entity Framework v4).
Example #1:
protected IQueryable<Database.Product> GetActiveProducts( ObjectSet<Database.Product> products ) {
var allowedStates = new string[] { "Active" , "Pending" };
return (
from product in products
w...
This is what my entities look like:
I'm essentially trying to make a left outer join between LookupMakeModel and LookYearMakeModel for a given year. I plan on selecting a valid year from a dropdownlist and then showing a table of all the records in LookMakeModel and checking the checkbox for the LookMakeModels that have a record in L...
I'm using Entity Framework 4 and having trouble with a query.
I have two objects:
Instruction
Component
Between these objects there's a many-to-many relation. An Instruction van point to one or more Components. And a Component can be referenced by multiple Instructions.
I am trying to get how many 'finished' (status = 6) Instructions...
Hello all.
I’m having fun with EF and have come unstuck.
Originally I used the following bit of code using standard linq that essentially enters some data into a table.
ManagePreferencesDataContext manpref = new ManagePreferencesDataContext();
tblManagePreference prefMemberID = new tblManagePreference();
...
As we all know most apps have a data access layer, often using repository classes. Typically we want the repository to operate with strongly typed objects, e.g.
interface IUserRespository
{
User GetUserByID(int id);
void AddUser(User u);
... and so on
}
However, sometimes we want to make a more complex query on a DB, ...
Hi guys I need to rewrite the sql query below using Linq to entity. Unfortunately I don't have a lot of experience of using Linq. Please help me
With TempTableName AS
(SELECT [ColumnName],
[ColumnName2],
[ColumnName3],
[ColumnName4],
ROW_NUMBER() OVER (order by ColumnName desc) as RowNumber from TableNam...
I have (well had) a bit of code that would get me my lovely username and populate a session with its contents:
ManagePreferencesDataContext lg = new ManagePreferencesDataContext();
IEnumerable<tblManagePreference> ol;
ol = from login in lg.tblManagePreferences
where login.Username == Membership....
Following on from the excellent answer to my previous question:
http://stackoverflow.com/questions/3220155/linq-entity-framework-generic-filter-method
I am now trying to understand how I can apply something like recursion to my solution.
To recap, instead of multiple similar declarations of this method:
protected IQueryable<Database....
Hi, I have a EF4 model where I have Product entity that have one-to-many relation with Task entity (ChildTasks). I have to get some Projects from db based on some user criteria. The Project has one custom property (not associated with any column) named EstimatedProgress where I have to store additional information about Project - compute...
I have an EF 4.0 model that has a parent child relationship (say order and orderdetails)
order
{
[primative]
orderid,
ordername,
ordershipping
[navigation]
orderdetails
}
orderdetail
{
orderdetailid,
orderpartid,
orderquantity,
orderpartname
}
My question is how do i load orders with orderdetails where the ...
I am new to LINQ to Entities and need some guidance about how to think about multiple row updates. My problem is actually more conceptual than syntactical as I am not sure if I am even thinking about the solution correctly.
Here is a single row update. This seems very straightforward.
products prodtbl = (from p in db.products where p....