手动添加新实体 [英] Add a new Entity manually
问题描述
我有一个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.
我会尝试的:
- 为用户"表创建一个新的列表和详细信息"屏幕(还包括UserApplications).
- 添加新用户(无自定义代码,使用LS的默认添加"按钮).
- 检查以查看是否只能添加一个新用户,而不能添加UserApplications.
- Create a new List and Details Screen for User table (also include the UserApplications).
- Add a new User (no custom code, use the default Add button of LS).
- Check to see if you're able to add just a new User and no UserApplications.
伊恩
这篇关于手动添加新实体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!