ADO.NET :: Insert Records Using LINQ To ENTITY?
Mar 16, 2011
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 Replies
Similar Messages:
Nov 22, 2010
How can i insert,update and delete records using entity framework data model.
View 1 Replies
Feb 23, 2011
how to insert records in multiple table using with foreign key with linq to sql?
View 2 Replies
Apr 29, 2010
I am using LINQ Expression to insert records in SQL Table. My Table dosen's have any Primary Key Field. Whenever I Am trying to Insert Records in Table using LINQ Expression, this always occurs an Error that 'the Table You are using to insert Dosen't Have Any Primary Key Field.
How I Will Insert Records Without Having Primary Key ?
View 1 Replies
Feb 9, 2011
I get an cast exception when i am trying to insert an entity in Entity Framework (using code-first). From this code :
public virtual T Insert(T entity)
{
return Context.Set<T>().Add(entity);
}
The cast exception is like "impossible to cast ...Collection'1(Entity) to type (Entity)" I can't figure out why. I am pretty sure ive done everything right. Post entity
public class Post
{
public long PostId { get; private set; }
public DateTime date { get; set; }
[Required]
public string Subject { get; set; }
public User User { get; set; }
public Category Category { get; set; }
[Required]
public string Body { get; set; }
public virtual ICollection<Tag> Tags { get; private set; }
public Post()
{
Category = new Category();
if (Tags == null)
Tags = new Collection<Tag>();
}................................
View 9 Replies
Nov 10, 2010
[Code]....
this is my html code
[Code]....
this is my code behind
[Code]....
this is my bal code
acuttally
in my javascript popup i am getting the checked values but i need it in record by record in the lblsave data
View 2 Replies
Dec 24, 2010
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?
View 2 Replies
Jun 30, 2010
Conseptually what I'm doing is simple, and technically it may even be simple, but I'm still rusty. Here's what I'm trying to do:
I have a webform that allows the user to enter a new record, and in there I have also included a couple FileUpload controls. Upon clicking the "Save" button, I'm saving the details entered into one table (ITEMS), and also inserting the FileUpload details (path, id, upload_user) into another table ATTACHMNTS). Because one ITEM can have many attachments, I needed to split the tables up. So on save, I need to save the ITEM, save the ATTACHMENT, and then also put the ITEM_ID in the ATTACHMENT table. I'm second guessing myself because I think all I'd have to do is after I do the ITEM insert, do a SELECT MAX on the ITEM table and hold the newest (MAX) id in a variable and then use it in the ATTACHMENTS update. I'm not 100% on this because there IS a chance that someone else could save a few milliseconds later and I'll link the wrong ITEM. See my delima?
View 7 Replies
Sep 4, 2010
I have the code below could to rewrite from LINq to SQL to Linq to Entity.
[code].....
View 1 Replies
Dec 26, 2010
How do I get the number of records in an entity?
This was so simple in VB6.....
View 9 Replies
Jul 28, 2010
I am working with VS 2010, Entity framework, SQl-Server 2005, ASP.Net web forms. Currently, I am working on the Data access layer library which soon will be a web service, using Entity Framework collaboration with different design patterns like repository pattern and some best practices that posts in different blogs. I am also test each repository using the Unit testing project. Thumbs up! Working fine.
The thing I am worried about is, how much is good for retrieving data from a table that can contain 80-100k records ?
View 1 Replies
Mar 21, 2011
Whats the best method to use with MVC? Entity Framework or LINQ to SQL?
View 4 Replies
Aug 5, 2010
Im 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 Replies
Dec 15, 2010
I'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 Replies
Dec 6, 2010
Im new to development for the windows server platform. Can someone tell me the difference between Linq to SQL and EF4?
View 2 Replies
Oct 13, 2010
Type '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??
View 1 Replies
Jun 11, 2010
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();
View 1 Replies
Oct 11, 2010
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 Replies
Oct 26, 2010
Could any one explain me which ORM is best?
View 3 Replies
Oct 29, 2010
I 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 Replies
Jul 12, 2010
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.
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
View 1 Replies
Oct 14, 2010
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.
View 1 Replies
Feb 2, 2010
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 Replies
Jan 14, 2010
I 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]....
View 1 Replies
Dec 15, 2010
I 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]....
View 2 Replies