手动添加新实体 [英] Add a new Entity manually

查看:76
本文介绍了手动添加新实体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个User表和ApplicationsUsers表.有一对多(1个用户可以有许多applicationUsers记录). LS可以毫无问题地进行设置.

I have a User table and a ApplicationsUsers table. There is a one to many (1 user CAN HAVE many applicationUsers records). LS sets this up with no problem.

我有 简单的屏幕,并带有添加按钮.应该使用添加按钮手动创建一个新的用户记录.这是代码:

I have  simple screen with an add button. The add button is supposed to manually just create a new User record. Here is the code:

用户u = this.AllUsers.AddNew();
                    u.FirstName ="Test";
                    u.LastName ="Me";

User u = this.AllUsers.AddNew();
                    u.FirstName = "Test";
                    u.LastName = "Me";

this.DataWorkspace.DataSource_DevData.SaveChanges();

this.DataWorkspace.DataSource_DevData.SaveChanges();

然后LS向我抛出此错误"UserApplications记录中的数据无效"

LS then throws this error at me "INVALID Data in the UserApplications Record"

User表中没有任何其他字段(UserID除外,它是主键)和ApplicationsUsers的导航属性.我不明白要进行此保存工作需要做什么.有人可以帮忙吗?

There aren't any other fields in the User table (other than UserID, which is the primary Key) and the navigation property for ApplicationsUsers. I don't understand what needs to be done here to make this save work. Can someone help?

 

谢谢!

推荐答案

我不知道您的应用程序的确切配置,但是根据您的描述,听起来就像LS抱怨添加新用户时UserApplications为空.

I don't know the exact configuration of your app, but based on your description, it sounds like LS is complaining that UserApplications is empty when you're adding a new User.

我会尝试的:

  1. 为用户"表创建一个新的列表和详细信息"屏幕(还包括UserApplications).
  2. 添加新用户(无自定义代码,使用LS的默认添加"按钮).
  3. 检查以查看是否只能添加一个新用户,而不能添加UserApplications.
  1. Create a new List and Details Screen for User table (also include the UserApplications).
  2. Add a new User (no custom code, use the default Add button of LS).
  3. Check to see if you're able to add just a new User and no UserApplications.

伊恩

 


这篇关于手动添加新实体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆