- xml - AJAX/Jquery XML 解析
- 具有多重继承的 XML 模式
- .net - 枚举序列化 Json 与 XML
- XML 简单类型、简单内容、复杂类型、复杂内容
我在一家公司实习,我必须使用 SAPUI5 框架在 JS 中编写代码。这对我来说是全新的,这就是为什么我按照 http://sapui5.hana.ondemand.com 上的教程进行操作的原因。 .但是现在我遇到了一个问题,在网上找不到任何建议,我也不能总是让同事帮我,他们也有工作......
我必须对许多员工及其任务进行规划。我使用带有 metadata.xml 文件的模拟服务器:
<edmx:Edmx xmlns:edmx="http://schemas.microsoft.com/ado/2007/06/edmx"
Version="1.0">
<edmx:DataServices
xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"
m:DataServiceVersion="1.0">
<Schema xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices"
xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"
xmlns="http://schemas.microsoft.com/ado/2008/09/edm" Namespace="NorthwindModel">
<EntityType Name="Employee">
<Key>
<PropertyRef Name="EmployeeID" />
</Key>
<Property xmlns:p8="http://schemas.microsoft.com/ado/2009/02/edm/annotation"
Name="EmployeeID" Type="Edm.Int32" Nullable="false"
p8:StoreGeneratedPattern="Identity" />
<Property Name="LastName" Type="Edm.String" Nullable="false"
MaxLength="20" Unicode="true" FixedLength="false" />
<Property Name="City" Type="Edm.String" Nullable="false"/>
<Property Name="Team" Type="Edm.String" Nullable="false"/>
<NavigationProperty Name="Appointments" Relationship="NorthwindModel.FK_Employees_Appointment"
FromRole="Employees" ToRole="Appointments"/>
</EntityType>
<EntityType Name="Appointment">
<Key>
<PropertyRef Name="AppointmentID"/>
</Key>
<Property Name="AppointmentID" Type="Edm.Int32" Nullable="false"/>
<Property Name="EmployeeID" Type="Edm.Int32" Nullable="false"/>
<Property Name="start" Type="Edm.DateTime" Nullable="false"/>
<Property Name="end" Type="Edm.DateTime" Nullable="false"/>
<Property Name="title" Type="Edm.String" Nullable="false"/>
<NavigationProperty Name="Employees" Relationship="NorthwindModel.FK_Employees_Appointment"
ToRole="Employees" FromRole="Appointments"/>
</EntityType>
<Association Name="FK_Employees_Appointment">
<End Type="Employee" Role="Employees" Multiplicity="1" />
<End Type="Appointment" Role="Appointments" Multiplicity="*" />
<ReferentialConstraint>
<Principal Role="Employees">
<PropertyRef Name="EmployeeID" />
</Principal>
<Principal Role="Appointments">
<PropertyRef Name="EmployeeID" />
</Principal>
</ReferentialConstraint>
</Association>
</Schema>
<Schema xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices"
xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"
xmlns="http://schemas.microsoft.com/ado/2008/09/edm" Namespace="ODataWeb.Northwind.Model">
<EntityContainer
xmlns:p7="http://schemas.microsoft.com/ado/2009/02/edm/annotation"
Name="NorthwindEntities" p7:LazyLoadingEnabled="true"
m:IsDefaultEntityContainer="true">
<EntitySet Name="Employees" EntityType="NorthwindModel.Employee" />
<EntitySet Name="Appointments" EntityType="NorthwindModel.Appointment"/>
<AssociationSet Name="FK_Employees_Appointments" Association="NorthwindModel.FK_Employees_Appointment">
<End Role="Employees" EntitySet="Employees"/>
<End Role="Appointments" EntitySet="Appointments"/>
</AssociationSet>
</EntityContainer>
</Schema>
</edmx:DataServices>
(对于AssociationSet和NavigationProperty标签,我是因为在我用的OData服务上看到过,但是没看懂,估计没问题。。。)
现在是 Appointments.json 文件:
[
{
"AppointmentID" : 0,
"EmployeeID" : 0,
"start":"\/Date(1466416800000)\/",
"end":"\/Date(1466424000000)\/",
"title": "test"
},{
"AppointmentID" : 1,
"EmployeeID" : 1,
"start":"\/Date(1466409600000)\/",
"end":"\/Date(1466416800000)\/",
"title": "test2"
}]
Employees.json 文件:
[
{
"EmployeeID":0,
"LastName":"APERCE",
"City":"Paris",
"Team":"Dev"
},
{
"EmployeeID":1,
"LastName":"HACHMI",
"City":"Lille",
"Team":"Dev"
},
{
"EmployeeID":2,
"LastName":"MILLET",
"City":"Paris",
"Team":"Admin"
},
{
"EmployeeID":3,
"LastName":"CORNET",
"City":"Poitiers",
"Team":"Admin"
},
{
"EmployeeID":4,
"LastName":"EVAIN",
"City":"Paris",
"Team":"R&D"
}]
(如您所见,EmployeeID 存在于 Appointments.json 和 Employees.json 中)
最后是 Overview.view.xml 文件:
<mvc:View controllerName="sap.ui.demo.wt.controller.Overview"
xmlns="sap.m" xmlns:mvc="sap.ui.core.mvc" xmlns:semantic="sap.m.semantic"
xmlns:unified="sap.ui.unified"
xmlns:core="sap.ui.core" displayBlock="true">
<semantic:FullscreenPage title="{i18n>overviewPageTitle}">
<VBox>
<PlanningCalendar startDate="{path : '/Startdate'}" rows="{path : 'data>/Employees',parameters:{expand:'Appointments'}}"
appointmentSelect="handleAppointmentSelect">
<rows>
<PlanningCalendarRow title="{data>LastName}"
appointments="{path : 'data>Appointments',templateShareable:true}">
<appointments>
<unified:CalendarAppointment
startDate="{data>start}"
endDate="{data>end}"
title="{data>title}">
</unified:CalendarAppointment>
</appointments>
</PlanningCalendarRow>
</rows>
</PlanningCalendar>
</VBox>
</semantic:FullscreenPage>
(“数据”模型已经与 metadata.xml 绑定(bind)并获取 Appointments.json 和 Employees.json)
实际上,这段代码为我计划中的每个员工显示了 Appointments.json 中的两个任务。我想绑定(bind)它,以便仅针对员工“APERCE”进行约会“test”,而仅针对“HACHMI”进行约会“test2”,但我不能。
我相信可以对 SQL 数据库执行与 JOIN 等效的操作,但我没有找到任何相关信息。我应该怎么做?感谢您的回答。
PS : 我是法国人,如果你不明白我上面写的,对不起;如果你能用法语回答,那就这样吧,这样对我的理解会更好。
编辑: 我已根据 nistv4n 的建议更正了代码。现在我收到以下错误:
MockServer: Resource not found for the segment 'Appointment' => 我明白,'Appointment' 段不存在,因为它是 'Appointments',但我不知道在哪里我忘记了“s”。
出现以下问题:HTTP 请求失败404,未找到,{"error":{"code":404,"message":{"lang":"en","value":"Resource not found for the segment 'Appointment'"}}} => 我猜这与之前的错误有关,因为它请求的是 'Appointment' 而不是 'Appointments' ?
REEDIT: 我把“s”放在正确的地方。现在我只有:无法读取未定义属性 'getTime' => 因为 Overview.view.xml 中使用的模型有问题,可能在 中,但如果我使用它是一样的:“{Appointments/start}” 、“{Appointments>start}”、“{start}”或“{/Appointments>start}”。
LASTEDIT:感谢 nistv4n,我终于做到了。如果您有同样的问题,我已经更新了上面的代码。正确的代码位于 PlanningCalendarRow => appointments="{path : 'data>Appointments'}" 和 unified:CalendarAppointment => startDate="{data>start}" 等...
实际上,引用 nistv4n 的话:“约会有一个相对引用,内部属性(开始、结束、标题)也有一个相对引用,包括模型名称。”
最佳答案
在为 PlanningCalendar
的聚合行定义绑定(bind)的地方,包括 $expand
关键字以使引用的事件可在容器中访问:
<PlanningCalendar startDate="{path : '/Startdate'}" rows="{path : 'data>/Employees', parameters:{expand:'Appointment'}}"
appointmentSelect="handleAppointmentSelect">
它将获取指定员工的分配Appointment
数据。您可以使用聚合内的 Appointment/start
绑定(bind)路径来引用它。
编辑:您似乎错过了第一个模式中的关联节点。像这样定义它:
<Association Name="FK_Employees_Appointment">
<End Type="Employee" Role="Employees" Multiplicity="1" />
<End Type="Appointment" Role="Appointments" Multiplicity="*" />
<ReferentialConstraint>
<Principal Role="Employees">
<PropertyRef Name="EmployeeID" />
</Principal>
<Principal Role="Appointments">
<PropertyRef Name="EmployeeID" />
</Principal>
</ReferentialConstraint>
</Association>
我建议只定义两个实体之间的单向连接。
您能否将您的代码发布到某个地方(即使是在 zip 存档中)以研究整个架构和代码线?
编辑 2:请根据此更改 View XML 的 PlanningCalendarRow
部分:
<PlanningCalendarRow title="{data>LastName}"
appointments="{path : 'data>Appointments',templateShareable:true}">
<appointments>
<unified:CalendarAppointment
startDate="{data>start}"
endDate="{data>end}"
title="{data>title}">
</unified:CalendarAppointment>
</appointments>
</PlanningCalendarRow>
Appointments
有一个相对引用,内部属性(start
、end
、title
)也有一个相对引用,包括型号名称。
关于javascript - SAPUI5 元数据.xml : binding two entities,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37924827/
我有这些实体(这只是我为这篇文章创建的抽象): 语言 区 说明 这些是它们之间的引用: 区 * - 1 语言 说明 * - 1 语言 区 1 - 1 说明 如果我这样取: var myFetch =
经过大量谷歌搜索后,除了降级 hibernate 版本之外,我没有找到问题的答案。但我在 2003 年类似的帖子中遇到了这种情况。 问题是什么: //in the first session I d
我听说过 linq to entities 。 Entity Framework 是利用linq to entities吗? 最佳答案 LINQ to Entities 是 Entity Framew
我是 Entity Framework 和 ASP.Net MVC 的新手,主要从教程中学习,对任何一个都没有深入了解。 (我确实有 .Net 2.0、ADO.Net 和 WebForms 方面的经验
如果我编写 LINQ to Entities 查询,该查询是否会转换为提供程序理解的 native 查询(即 SqlClient)? 或者 它是否会转换为实体 SQL,然后 Entity Framew
这个问题已经有答案了: EF: Include with where clause [duplicate] (5 个回答) 已关闭 2 年前。 看来我无法从数据库中获取父级及其子级的子集。 例如...
我开始在一家新公司工作,我必须在一个旧项目上使用 C++ 工作。所以,我忘记了一些 C++ 本身的代码结构。在一个函数中,我在一个函数中有双冒号::,但我不知道如何理解它。 例如,我知道如果我有 EN
我写了一个方法来允许为 orderby 子句传递一个表达式,但我遇到了这个问题。 Unable to cast the type 'System.DateTime' to type 'System.I
简单的问题:LINQ to Entities 和 Entity Framework 有什么区别?到目前为止,我认为这两个名称是用来描述同一个查询的,但我开始觉得事实并非如此。 最佳答案 Entity
我想使用 Entity Framework 。但是,我还要求允许我的用户在我们的系统中定义自定义字段。我想仍然使用 Entity Framework ,而不是使用具有哈希表属性的分部类。 下面是我想到
我正在阅读这个 E.F. 团队博客的这个系列 http://blogs.msdn.com/b/adonet/archive/2011/01/27/using-dbcontext-in-ef-featu
我正在使用 EF6 开发插件应用程序,代码优先。 我有一个名为 User 的实体的主要上下文。 : public class MainDataContext : DbContext { pub
当我得到最后的 .edmx 时,我遇到了问题。 我收到一条消息说 错误 11007:未映射实体类型“pl_Micro”。 查看设计器 View ,我确实看到该表确实存在。 我怎样才能克服这个消息? 最
我已阅读与使用 Entity Framework 时在 Linq to Entities (.NET 3.5) 中实现等效的 LEFT OUTER JOIN 相关的所有帖子,但尚未找到解决以下问题的方
使用 WCF RIA 服务和 Entity Framework 4. 我有 3 个 DTO:学校、州、区。 州 DTO 有一个地区属性(property),其构成。学校 DTO 有一个国家属性(pro
我有一个 Employee 实体,它继承自一个继承自 Resource 实体(Employee -> Person -> Resource)的 Person 实体。是否可以通过编程方式获取 Emplo
我有一个使用 JPA 的 java 应用程序。 假设我有一个名为 Product 的实体与 name和 price属性(所有实体都有一个 id 属性)。 自然我可以得到一个List相当容易(来自查询或
我有一个 Entity Framework 类,其中有两个指向另一个对象的引用 public class Review { [Key] public int Id {get;s
我是 Symfony 2 的新手,我想知道一些事情: 假设我的项目中有 2 个 bundle 。我想在两个包中使用从我的数据库生成的实体。 我应该在哪里生成实体? (对我来说,最好的方法是在 bund
我想在具有方法和属性的部分类中扩展 EF 实体。我经常这样做。 但是现在我需要将来自该实体的数据与来自其他实体的数据结合起来。因此,我需要能够访问实体 objectcontext(如果附加)来进行这些
我是一名优秀的程序员,十分优秀!