C# - How To Convert Linq To SQL To Linq Entity
Sep 4, 2010I have the code below could to rewrite from LINq to SQL to Linq to Entity.
[code].....
I have the code below could to rewrite from LINq to SQL to Linq to Entity.
[code].....
We would like to perform something like this
string strCondition = "FirstName=='abc'"
from p in People.Where(strCondition) select p
In our architecture we are usign both Linq-Sql as well Linq-Entity. So please give some thoughts wehter it is possible or not and is there any way to perform this?
Whats the best method to use with MVC? Entity Framework or LINQ to SQL?
View 4 RepliesIm working on a greenfield project and have to make a decision on the technology we'll use for the data access layer. Ive used LINQ to SQL for a few years and am happy and comfortable with this, but now with entity framework available this is another method to consider. Are there any pitfalls using entity framework as opposed to LINQ to SQL ? Ive read that there are performance issues with entity framework, is this true? Id really like to get an overall feel for using one method over the other, anyone have any thoughts/comments/recomendations?
View 1 RepliesI'm trying to learn MVC. Now I wonder whats the different between entity framework and LINQ TO SQL? Wich is the best to use and why?
View 19 RepliesIm new to development for the windows server platform. Can someone tell me the difference between Linq to SQL and EF4?
View 2 RepliesType 'System.Data.Linq.ChangeTracker+StandardChangeTracker' in Assembly 'System.Data.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' is not marked as serializable
have read all threads but still cant solve the error. I can do insert update and delete but dont know where exactly the error occurs and how??
How can I update an existing LINQ entity? This code gives me: "Cannot insert an entity that already exists."
Any better practises on updating/inserting with linq?
foreach (ListViewItem lvi in lvStudents.Items)
{
HiddenField hfStudentID = lvi.FindControl("hfID") as HiddenField;
CheckBox cbPresent = lvi.FindControl("mycb") as CheckBox;
int sInt = Int32.Parse(hfStudentID.Value);
dc = new DataClassesSODataContext();//I renewed the dc to make sure that wasn't the problem?
var currStudent = dc.students.Single(x => x.studentID == sInt);
grade g = dc.grades.Single(x => x.subjectID == subjID || x.studentID == sInt);
if (g == null)
{
g = new grade();
g.subject = dc.subjects.Single(x => x.subjectID == subjID);
g.student = currStudent;
g.present = cbPresent.Checked;
dc.grades.InsertOnSubmit(g);
} else
{
g.present = cbPresent.Checked;
dc.grades.Attach(g, true);//I tried both attaching and inserting
}
}
dc.SubmitChanges();
what is diffrence between Entity Framework and LINQ to SQL i cant yet find a good blog on this i have read that in LINQ to SQL only one to one mapping is possible but Entity Framework allowes many , is it right? if so i dont understand this
View 3 RepliesCould any one explain me which ORM is best?
View 3 RepliesI have a new project where I want to use MVC (I will be learning as I code), and I have never used linq or entity (or mvc). Which should I use? Does it matter? I will be having a lot of different databases, from Oracle to FoxPro.
View 6 RepliesHi 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.
With TempTableName AS
(SELECT [ColumnName],
[ColumnName2],
[ColumnName3],
[ColumnName4],
ROW_NUMBER() OVER (order by ColumnName desc) as RowNumber from TableName )
SELECT
[ColumnName],
[ColumnName2],
[ColumnName3],
[ColumnName4]
FROM TempTableName WHERE ROWNUMBER
Between 10 and 100
i have a database with 4 table aspnet_Users, Forum, Topic, Post thay are related:
aspnet_Users with Topic by UserId
Forum with Topic by ForumId
Topic with Post by TopicId
i created a linq to get data from Database like:
[Code]....
now i need to get also how meny post are in a topic but i don't know how to write the querry.
select * from MyTable select "MonthName"= case when datepart(month,date1) =1 then 'January' when datepart(month,date1) =2 then 'February' end , count(*) as CountByMonth from venkat group by datepart(month,date1)
View 1 RepliesI am using the following LINQ to entity to get data from my db.
It should return only one row. So i want to be able to get the first row in the set and not have to go through a foreach.
I would also like to check and make sure it is only returning one row, if it returns multiple i need to throw an exception
[Code]....
I worked with LINQ to SQL to insert and delete the data,but i want to use LINQ TO ENTITY to insert the data but i know LINQ to ENTITY is used for querying the database.I have searched the code for inserting records but i dint get any.
View 7 RepliesI am selecting some products from database and would like to show them in client's grid using WCF. Problem is I don't know how to pass selected collection to the client since my method can't return that data type.
My method:
public class Service1 : IService1
{
public ProductData GetData(int value)
{
using( NorthwindEntities NWEntities = new NorthwindEntities()){
[Code]....
When do I need (/ best practice) to use views and stored procedures in my database when using linq with the entity framework?
View 8 RepliesI am tasked to build a web 2.0 style mashup application which consumes a lot of 3rd party webservices like youtube and twitter. There are also lots custom features which are going to be built using ASP.NET 3.5 and SQL Server 2008. Now I am looking for the right ORM for my needs. From a performance and ease of use standpoint can anyone suggest me the right ORM for this kind of web application?
View 1 RepliesOrder by descending is not working on LINQ to Entity In the following Query In place of ascending If I keep descending it is not working.
[code]....
I have the data coming from Entity Data model table on my ASP.NET page.
Now I have to export this data into Excel on button click.
If it is using OLEDB, it is straight forward as it is here: [URL]
Here is my function to read data from inquiries table:
[code]....
I have extended a Entity class created by the designer (Linq to SQL). I have create a partial class called Promotion (App_Code/Promotion.cs) and I have added some new methods. But now, I want to access this methods from a FormView control and I dont know how to refer to the instance of the entity.
In the ForView, I can do:
[Code]....
And now Im accessing to one STATIC method of my completed Promotion class (App_Code/Promotion.cs)
But I dont know how to do to call a instance method
[Code]....
My firs though was to use the reserved word this, jejeje, but this refer to the web page instance..
i have 2 table missions and missiondays with a relationship 1..n
I want select all missions that has all missiondays with an attribute called "visible" = true
I've tried with:
db.TDP_Missioni.Include("TDP_MissioniDestinazioni").where(p => p.TDP_MissioniDestinazioni.visible == true)
But there is an error. Indeed from p.TDP_MissioniDestinazioni i don't see the table's attributes. I think it's because the relationship is 1..n.
var query = from p in dc.Patients
select p.PAge;
Can i get PAge value in an any int like....
int PAge = query.Single();
I'm trying Convert.ToInt32(-----------------)
but this give me Error on run time
Need to figure out the correct way to do a simple SUM function in Linq, but also manipulate one of the feilds coming back by doing a Substring on it, here is the original SQL query:
[Code]....