.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Post New Web Links

WCF DataService : basic Order - OderDetail - Product use case - unable to persist

Posted By:      Posted Date: September 10, 2010    Points: 0   Category :WCF
Hello, I have the very classical Order - OderDetail - Product use case. I've made my database, my entity framework model and exposed it as a DataServices Read/Write. Order, OrderDetail and Product table have a Id column which is a PK based on an IDENTITY column (auto incr) Form the client, I try the following : MyEntities session1 = new MyEntities(svcUri); Order o = new Order(); session1.AddToOrder(o); o.OrderDate = DateTime.Now; Product p1 = new Product(); session1.AddToProduct(p1); p1.ProductDescription = "Product1"; Product p2 = new Product(); session1.AddToProduct(p2); p2.ProductDescription = "Product2"; OrderDetails d1 = new OrderDetails() {Product = p1, Amount = 1}; session1.AddToOrderDetails(d1); o.OrderDetails.Add(d1); var response1 = session1.SaveChanges(SaveChangesOptions.Batch); I receive the following error : Unable to determine the principal end of the 'MyEntities.FK_OrderDetails_Product' relationship. Multiple added entities may have the same primary key. I try to initialize every Id (PK)  of every object I create on the client using temporary values (-1,-2,-3,...) and then I got an other error message : The INSERT statement conflicted with the FOREIGN KEY constraint \"FK_OrdeDetails_Order\". The conflict occurred in database \"MyEntities\", table \"dbo.Order\", column 'OrderId'.&a

View Complete Post

More Related Resource Links

Linq qry with order by basic questions


I have never tried a group by with linq, now I do and I'm stuck.

I try to convert this sql statement to its linq counterpart :

SELECT COUNT(tb_Mailer_Smses.Id) AS [cnt], tb_Mailer_mailing.Id As [Id]
,SUM( CASE WHEN tb_Mailer_smses.DLRStatus = 200 THEN 1 ELSE 0 END) As [Delivered]
FROM tb_Mailer_mailing INNER JOIN
tb_Mailer_Smses ON tb_Mailer_mailing.Id = tb_Mailer_Smses.MailingId
WHERE tb_Mailer_mailing.ApplicationId = 1
GROUP BY tb_Mailer_mailing.Id

Is there some one who can me show me the convertion process ?

Unable to enter the product key in the Convert License Type page (textbox is read-only)

We installed both WSS and MOSS SP2 and had planned to follow the manual fix for the known issue that the patch unexpectedly activates a trial expiration.  However, the textbox to enter the product key is read-only.  We have tried accessing this page using the normal administrator credentials as well as the farm account; no success.The SP2 issue and manual fix is detailed here, http://support.microsoft.com/default.aspx/kb/971620We were able to experience this problem on a farm running the Feb 2007 cummulative patch (version so it's not related to the SP.  But running the SP increasing the need to find the fix.Any help is appreciated,J. Aqui

Persist sort order in datagrid



I've got multiple datagrids in the application I'm currently working on. Their ItemSource can be updated with new content on server notifications. When this happens, the ItemSource is being replaced by a new one (would it be better to update the content of the ItemSource - which is much more complicated for this case of figure - instead of binding a new one?)

When the new ItemSource is being bound, the sorting of the grid is being lost. I've solved this behaviour by saving the sorting before setting the new binding and restoring it after the new binding has been done. Below you'll find the static methods used for that:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Windows.Controls;
using System.Windows.Data;
using Telecontrol.SIPPR.Client.Commons.DataObjects;

namespace Telecontrol.SIPPR.Client.Commons.Utils
  public static class DataGridUtil

Order by sum using case?

SELECT fldFSL, Login, BranchName, 

SUM(CASE WHEN YEAR(DateVisited) = YEAR(getdate()) AND MONTH(DateVisited)= 1 THEN 1 ELSE 0 END) AS Jan,
SUM(CASE WHEN YEAR(DateVisited) = YEAR(getdate()) AND MONTH(DateVisited) = 2 THEN 1 ELSE 0 END) AS Feb, 
SUM(CASE WHEN YEAR(DateVisited) = YEAR(getdate()) AND MONTH(DateVisited) = 3 THEN 1 ELSE 0 END) AS Mar, 
SUM(CASE WHEN YEAR(DateVisited) = YEAR(getdate()) AND MONTH(DateVisited) = 4 THEN 1 ELSE 0 END) AS Apr, 
SUM(CASE WHEN YEAR(DateVisited) = YEAR(getdate()) AND MONTH(DateVisited) = 5 THEN 1 ELSE 0 END) AS May, 
SUM(CASE WHEN YEAR(DateVisited) = YEAR(getdate()) AND MONTH(DateVisited) = 6 THEN 1 ELSE 0 END) AS Jun, 
SUM(CASE WHEN YEAR(DateVisited) = YEAR(getdate()) AND MONTH(DateVisited) = 7 THEN 1 ELSE 0 END) AS Jul,
SUM(CASE WHEN YEAR(DateVisited) = YEAR(getdate()) AND MONTH(DateVisited) = 8 THEN 1 ELSE 0 END) AS Aug,
SUM(CASE WHEN YEAR(DateVisited) = YEAR(getdate()) AND MONTH(DateVisited) = 9 THEN 1 ELSE 0 END) AS Sep, 
SUM(CASE WHEN YEAR(DateVisited) = YEAR(getdate()) AND MONTH(DateVisited) = 10 THEN 1 ELSE 0 END) AS Oct,
SUM(CASE WHEN YEAR(DateVisited) = YEAR(getdate()) AND MONTH(DateVisited) = 11 THEN 1 ELSE 0 END) AS Nov, 
SUM(CASE WHEN YEAR(DateVisited) = YEAR(getdate()) AND MONTH(DateVisited) = 12 THEN 1 ELSE 0 END) AS Dec

FROM         (SELECT top 100 percent dbo.tblBranch.fldFSL, db

Use HTTP Basic Auth and ASP.NET Membership Provider with WCF DataService


I have a WCF Data Service (inherits System.Data.Services.DataService<T>) that I need to secure using HTTP Basic Authentication. I also want to use the ASP.NET Membership Provider for validating username/password.

I've searched quite a bit online on how to do this. The only thing I found that'll work is to write a custom HttpModule to handle the HTTP Basic authentication.

There must be a way to configure WCF with a DataService<T> to use HTTP Basic Authentication with the ASP.NET Membership Provider. Does anyone know how to do this?

I also wouldn't be apposed to using OAuth 2.0 for authentication, but it still needs to use the ASP.NET Membership Provider.


Microsoft MVP - Windows Live Platform
Blog: http://pietschsoft.com  | Web.Maps.VE - ASP.NET AJAX Bing Maps Server Control

Unable to create two independent task using basic task workflow


Hi everyone,

recently I've tried to create Basic task workflow with SharePoint designer 2010. I followed tutorial step by step: http://www.sheltonblog.com/video/HiRes_BasicTaskWorkflow.wmv

But at the end the behavior of workflow was not what I expected. 

I created one custom list and task list.

When I add item to custom list the workflow is started. Workflow creates some task connected to the just created item. When I change task state to Complete the workflow should finish.

Everything works fine till I create two or more items in custom list, because all my tasks states are changed to Completed when  I change task of one item to Completed. After that all workflows at custom list are Completed.

I really don't understand where I did mistake because as I wrote above I followed tutorial step by step. 

This is used code:

private void createTask1_MethodInvoking(object sender, EventArgs e)
      createTask1.TaskProperties.AssignedTo = "Domain\\user";
      createTask1.TaskProperties.Title = 

ORDER BY and CASE statement not working with VARCHAR types


Hello all,

I cannot understand why this query won't work for some fields (VARCHAR ones):


	DECLARE @SortExpression as varchar(max) = null	
	SET @SortExpression = 'jobName'
	create table #TempJobHistory(
		[created] [datetime] NOT NULL,
		[clientName] [varchar](50) NOT NULL,	
		[startTime] [datetime] NOT NULL,
		[endTime] [datetime] NULL,			
		[jobName] [varchar](50) NULL,
		[exitCode] [int] NULL,
		[status] [varchar](20) NOT NULL,
		[rowNumber] [bigint] NOT NULL		

	insert into #TempJobHistory

Visual Case Tool - UML Tutorial

The Class Diagram

The class diagram is core to object-oriented design. It describes the types of objects in the system and the static relationships between them.

Use Case Diagram

The use case diagram shows the functionality of the system from an outside-in viewpoint.

Actors (stick men) are anything outside the system that interacts with the system.

WCF Tutorial - Basic Interprocess Communication

What the heck is WCF? For a long time, I couldn't tell you exactly what it was. And honestly, I still don't think I can. WCF is such a broad concept that it's hard to boil down into a concise explanation. When I finally started reading about it, and getting beyond the concepts, things started to clear up. That's what today's tutorial is about - cutting through all the concepts and just use WCF to build a basic server and a basic client.

How to run Office macros by using Automation from Visual Basic .NET

This step-by-step article describes how to call Office macros from a Visual Basic .NET Automation client.

You can use Microsoft Office Automation to open a document or create a new document that contains a Visual Basic for Applications (VBA) macro and execute the macro at run time.

learn basic about share point.

This learn basic about share point.

Dynamically Create Controls in ASP.NET with Visual Basic .NET

This step-by-step article describes how to dynamically create controls for an ASPX Web page.

The sample project does the following:
It creates two TextBox controls.
It verifies that the TextBox contents (TextBox.text) and attributes are saved across posts to the server.
It describes how events that are posted by a dynamically created control are handled.

Creating a Basic SharePoint Web Part

This programming task includes the steps for creating a basic custom Windows SharePoint Services Web Part. It is a simple Web Part that allows you to change the Web Part's Title property, which is a Windows SharePoint Services WebPart base class property that sets the text in the title bar of the Web Part.

all basic windows controls,wpf controls,silverlight application

here you will find all the information from basic.

Basic Support


Can anyone help me please?


I have been producing a registration form using html and asp.  I have managed to get it to send an email having copied script from a previous website which someone developed for me.  I now get the response going to the old address and with then old text.  How can I change it all to the new site?

This has been very frustrating as I am sure someone is going to say all I have to do is ...




Textbox in ItemTemplate inside Gridview, unable to get the value


Hi. I have a itemtemplate inside a gridview.

<asp:TemplateField HeaderText="Enter OTP">
                            <asp:Label ID="Label2" runat="server"
                                style="font-family: Arial, Helvetica, sans-serif; font-size: x-small"
                                Text="PIN Num:"></asp:Label>
                            &nbsp;<asp:TextBox ID="txtPIN" runat="server" Height="21px" Width="100px"></asp:TextBox>

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend