LINQ to SQL - Get operation with DBML going infinite loop.
-
2012년 2월 9일 목요일 오전 9:56
Hi all ,
I have created a simple db with following tables.
Customer
1) Customer id - PK
2) First name
3) Last name
Order
1) Orderid - PK
2) Customer ID - FK
3) Order date
4) Comments
Order details
1) OrderDetailId - PK
2) Orderid - FK
3) Product id - FK
Product
1) Product Id -PK
2) Product name
After this , I have added a LINQ to SQL dbml files and dropped these 4 tables. I am fetching customer list from datacontext object as var custList = from c in dbContext.customers select c.
Problem -
This operation works fine when there is no data in order and order detail table. But once I save data in order and order detail table for a particular customer , it goes in infinite loop and operation never completes. It is bit strange..
Can someone please help me out with this?
Siddhesh
모든 응답
-
2012년 2월 9일 목요일 오후 4:46
Hi Siddhesh;
Can you post the code you use to update Customer, Order, and Order Detail tables. Also show the code that causes the query to go into an infinite loop.
Fernando (MCSD)
If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful". -
2012년 2월 10일 금요일 오전 6:20
Hi fernando ,
Customer is a master table . No DML operations on customer .
To insert data in order and order detail I am using a SP which takes parameters as
@Comment
@OrderDate
@CustomerId
@Total
@ShipMethod
@ProductId
Where @product ID is comma seperated string of products. SP does simple insertion in Order table first . Then it takes OrderId as Identity and use this to do insertion in order detail table for each product Id.
--------------------------------------------------------------------------------------------------------------------------------------------------------------------
I am using this SP with DBML and WCF service just calls this SP as
{
int insertStatus = dataContext.InsertOrder(order.Comment, DateTime.Now, order.CustomerId, order.Total, order.ShipMethod, productIds);return insertStatus;
}
---------------------------------------------------------------------------------------------------------Also following is WCF function which gets customer list and goes in infinite loop when I enter some data in Order and Order detail. It works fine when both tables are empty.
public List<Customer> GetCustomers()AdventureWorksDataContext dataContext = new AdventureWorksDataContext();
{
var custList = from c in dataContext.Customers
select c;
return custList.ToList();
}
- 편집됨 Siddhesh S 2012년 2월 10일 금요일 오전 6:20
- 편집됨 Siddhesh S 2012년 2월 10일 금요일 오전 6:21
-
2012년 2월 13일 월요일 오전 5:17중재자
Hi Siddhesh,
Welcome to MSDN Forum.
I have created the database as you posted and tested the code, everything works well. Because I don't know how you write the 'InsertOrder' Stored Procedure, so I insert the records mannually. If possible, please upload the demo to SkyDrive and post the link here, I will help you to solve the issue.
Best Regards
Allen Li [MSFT]
MSDN Community Support | Feedback to us
-
2012년 2월 14일 화요일 오전 9:43
Hi Allen ,
Thanks for reply .
I have uploaded insert script at following location on skydrive
https://skydrive.live.com/#cid=C8AE172EF094E6E5&id=C8AE172EF094E6E5%21107
I have also uploaded WCF service class (SVC ) and DBML designer class at following location.
https://skydrive.live.com/#cid=C8AE172EF094E6E5&id=C8AE172EF094E6E5%21109
Please let me know if you can access it.
Thanks
Siddhesh
Siddhesh Sawant
-
2012년 2월 14일 화요일 오후 2:15
Hi Siddhesh;
I tried downloading the files on your skydrive, either the files have been deleted or have not been marked for public viewing.
Fernando (MCSD)
If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful". -
2012년 2월 15일 수요일 오전 5:29중재자
Hi Siddhesh S,
As @Fernando said, the files have already deleted, so we can't download them.
Best Regards
Allen Li [MSFT]
MSDN Community Support | Feedback to us
-
2012년 2월 15일 수요일 오전 9:53
Hi Allen / fernando
I have uploaded WCF function , insert procedure and DBML class at following public folder.
https://skydrive.live.com/#cid=C8AE172EF094E6E5&id=C8AE172EF094E6E5%21105
Please let me know if you can access the files.
Thanks again for your help.
Siddhesh
Siddhesh Sawant
-
2012년 2월 15일 수요일 오후 6:34
Hi Siddhesh S;
From the code you posted I can see no reason for the problem you are having. Maybe Allen will spot something I was not able to.
Fernando (MCSD)
If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful". -
2012년 2월 16일 목요일 오전 8:21중재자
Hi Siddhesh,
I didn't find anything wrong with the code, I will do more research about it.
Best Regards
Allen Li [MSFT]
MSDN Community Support | Feedback to us
-
2012년 2월 17일 금요일 오전 7:20중재자
Hi Siddhesh,
Could you please upload the complete project to skydrive and post the link here? I want to test the project and try to find the reason, just from the code, I didn't find anything wrong.
Best Regards
Allen Li [MSFT]
MSDN Community Support | Feedback to us
-
2012년 2월 20일 월요일 오전 6:09
Hi Allen,
I have uploaded WCF service at following location
https://skydrive.live.com/#cid=C8AE172EF094E6E5&id=C8AE172EF094E6E5%21123
I have hosted this service on IIS 7 and consumed from silverlight client.
Please let me know if more details are required.
PS - strange thing is , I have tried out same with edmx (entity framework) and it works great. Not sure what is the issue with LINQ to SQL.
Thanks
Siddhesh
Siddhesh Sawant
-
2012년 2월 22일 수요일 오전 8:44중재자
Hi Siddhesh S,
I have involved my workmates to research the issue, it may need sometime, I will come back as soon as possible.
Best Regards
Allen Li [MSFT]
MSDN Community Support | Feedback to us
-
2012년 2월 23일 목요일 오전 7:04중재자
Hi Siddhesh,
I downloaded your project, the only problem I can see is: you should Set Serialization Mode to "Unidirectional" in AdventureWorksDataContext property(Right click designer--->properties).
Have a nice day.
Alan Chen[MSFT]
MSDN Community Support | Feedback to us
Get or Request Code Sample from Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.

-
2012년 2월 23일 목요일 오전 7:27
Thanks Alan chen ,
i will try it and let you know.
Siddhesh
Siddhesh Sawant
-
2012년 3월 9일 금요일 오전 7:16중재자
Hi Siddhesh,
Any updates for your question now, thanks!
Have a nice day.
Alan Chen[MSFT]
MSDN Community Support | Feedback to us
Get or Request Code Sample from Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.

-
2012년 3월 9일 금요일 오전 7:24
Hi Alan Chen ,
We have decided to use LINQ to entity ( Entity framework) instead of LINQ to SQL. Application works fine with Linq to Entitities framework.
Thanks all involved in this chain for your valuable inputs.
Siddhesh
Siddhesh Sawant
- 답변으로 표시됨 Alan_chenModerator 2012년 3월 9일 금요일 오전 7:28

