开发者

The insert method in the service "mysteries" inserts everything but not which I ask it to

I cannot understand the mistake.

error

None, but no records get inserted. nothing happens.

mysteries

The insert method in the service "mysteries" inserts everything but not which I ask it to.

For the customerid value it keeps on inserting numbers 30118 - 30119 and so on in every insert, irrespective of what I ask it to insert

xaml.cs

 /// </summary>
        public About()
        {
            InitializeComponent();

            this.Title = ApplicationStrings.AboutPageTitle;


            ServiceReference1.Customer new_customer = new ServiceReference1.Customer();
            //feeding data to the instance
            new_customer.CustomerID = 9999999;
            new_customer.NameStyle = false;
            new_customer.FirstName = "first_name";
            new_customer.LastName = "last_name";
            new_customer.PasswordHash = "password_hash";
            new_customer.PasswordSalt = "pass_salt";
            new_customer.rowguid = System.Guid.NewGuid();
            new_customer.ModifiedDate = System.DateTime.Now.Date;

            ServiceReference1.Service1Client client = new ServiceReference1.Service1Client();

            client.DoInsertCompleted += new System.EventHandler<System.ComponentModel.AsyncCompletedEventArgs>(client_DoInsertCompleted);

            client.DoInsertAsync(new_customer);
        }

        void client_DoInsertCompleted(object sender, System.ComponentModel.AsyncCompletedEventArgs e)
        {
            //throw new System.NotImplementedException();
            label1.Content = "Inserted";
        }

svc.cs

namespace BusinessApplication2.Web
{
    [ServiceContract(Namespace = "")]
    [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
    public class Service1
    {
        [OperationContract]
        public List<Customer> DoWork()
        {
            // Add your operation implementation here

            BusinessApplication2.Web.AdventureWorksLTEntities alpha = new AdventureWorksLTEntities();

            var selected_rows = from rows in alpha.Customers select rows;

            return selected_rows.ToList();
        }



        [OperationContract]
        public void DoInsert(Customer alpha)
        {

            //create db object
            BusinessApplication2.Web.AdventureWorksLTEntities db = new AdventureWorksLTEntities();
            //create a new table object
            Customer new_customer = new Customer();

            new_customer.CustomerID = alpha.CustomerID;
            new_customer.NameStyle = alpha.NameStyle;
            new_customer.FirstName = alpha.FirstName;
            new_customer.LastName = alpha.LastName;
            new_customer.PasswordHash = alpha.PasswordHash;
            new_customer.PasswordSalt = alpha.PasswordSalt;
            new_customer.rowguid = alpha.rowguid;
            new_customer.ModifiedDate = alpha.ModifiedDate;

            db.Customers.开发者_开发知识库AddObject(new_customer);
            db.AcceptAllChanges();
            db.SaveChanges();
            db.Dispose();

            return;


        }//insert to customer ends
    }
}


Are you certain that you do not have IdentityInsert turned off?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜