Skip to content

Instantly share code, notes, and snippets.

@FransBouma
Last active October 14, 2015 12:33
Show Gist options
  • Save FransBouma/af3740bb8c09974f6bcd to your computer and use it in GitHub Desktop.
Save FransBouma/af3740bb8c09974f6bcd to your computer and use it in GitHub Desktop.
Document setup for RethinkDB, fails to insert type info. How to configure it to do so? The 'Employees' collection contains the supertype, not the subtype 'Boardmember'. The test to check the result fails.
//------------------------------------------------------------------------------
// <auto-generated>This code was generated by LLBLGen Pro v5.0.</auto-generated>
//------------------------------------------------------------------------------
using System;
using System.ComponentModel;
using System.Runtime.Serialization;
using System.Xml.Serialization;
using System.Collections.Specialized;
using System.Collections.Generic;
namespace IHMMDocs.RethinkDB.DocumentClasses
{
/// <summary> Document class which is derived from the entity 'BoardMember'.</summary>
public class BoardMember
{
/// <summary>Gets or sets the CompanyCar field. </summary>
public BoardMemberTypes.CompanyCar CompanyCar { get; set; }
/// <summary>Gets or sets the CompanyCarId field. Derived from Entity Model Field 'BoardMember.CompanyCarId (FK)'</summary>
public Nullable<System.Int32> CompanyCarId { get; set; }
/// <summary>Gets or sets the EmployeeId field. Derived from Entity Model Field 'Employee.EmployeeId'</summary>
[Newtonsoft.Json.JsonProperty("id")]
public System.Int32 EmployeeId { get; set; }
/// <summary>Gets or sets the ManagesDepartmentId field. Derived from Entity Model Field 'Manager.ManagesDepartmentId (FK)'</summary>
public Nullable<System.Int32> ManagesDepartmentId { get; set; }
/// <summary>Gets or sets the ManagesDepartmentName field. Derived from Entity Model Field 'Department.Name (ManagesDepartment)'</summary>
public System.String ManagesDepartmentName { get; set; }
/// <summary>Gets or sets the Name field. Derived from Entity Model Field 'Employee.Name'</summary>
public System.String Name { get; set; }
/// <summary>Gets or sets the StartDate field. Derived from Entity Model Field 'Employee.StartDate'</summary>
public System.DateTime StartDate { get; set; }
/// <summary>Gets or sets the WorksForDepartment field. </summary>
public BoardMemberTypes.WorksForDepartment WorksForDepartment { get; set; }
/// <summary>Gets or sets the WorksForDepartmentId field. Derived from Entity Model Field 'Employee.WorksForDepartmentId (FK)'</summary>
public Nullable<System.Int32> WorksForDepartmentId { get; set; }
}
namespace BoardMemberTypes
{
/// <summary> Document class which is derived from the entity 'CompanyCar (CompanyCar)'.</summary>
public class CompanyCar
{
/// <summary>Gets or sets the Brand field. Derived from Entity Model Field 'CompanyCar.Brand'</summary>
public System.String Brand { get; set; }
/// <summary>Gets or sets the CarId field. Derived from Entity Model Field 'CompanyCar.CarId'</summary>
public System.Int32 CarId { get; set; }
}
/// <summary> Document class which is derived from the entity 'SportsCar (CompanyCar)'.</summary>
public class CompanyCarSportsCar: CompanyCar
{
/// <summary>Gets or sets the IsCabrio field. Derived from Entity Model Field 'SportsCar.IsCabrio'</summary>
public Nullable<System.Boolean> IsCabrio { get; set; }
}
/// <summary> Document class which is derived from the entity 'FamilyCar (CompanyCar)'.</summary>
public class CompanyCarFamilyCar: CompanyCar
{
/// <summary>Gets or sets the HasDrawHook field. Derived from Entity Model Field 'FamilyCar.HasDrawHook'</summary>
public Nullable<System.Boolean> HasDrawHook { get; set; }
}
/// <summary> Document class which is derived from the entity 'Department (WorksForDepartment)'.</summary>
public class WorksForDepartment
{
/// <summary>Gets or sets the Employees field. </summary>
public List<WorksForDepartmentTypes.Employee> Employees { get; set; }
/// <summary>Gets or sets the Name field. Derived from Entity Model Field 'Department.Name'</summary>
public System.String Name { get; set; }
}
namespace WorksForDepartmentTypes
{
/// <summary> Document class which is derived from the entity 'Employee (WorksForDepartment.Employees)'.</summary>
public class Employee
{
/// <summary>Gets or sets the Name field. Derived from Entity Model Field 'Employee.Name'</summary>
public System.String Name { get; set; }
}
/// <summary> Document class which is derived from the entity 'Manager (WorksForDepartment.Employees)'.</summary>
public class EmployeeManager: Employee
{
/// <summary>Gets or sets the ManagesDepartment field. </summary>
public EmployeeManagerTypes.ManagesDepartment ManagesDepartment { get; set; }
/// <summary>Gets or sets the ManagesDepartmentId field. Derived from Entity Model Field 'Manager.ManagesDepartmentId (FK)'</summary>
public Nullable<System.Int32> ManagesDepartmentId { get; set; }
}
/// <summary> Document class which is derived from the entity 'BoardMember (WorksForDepartment.Employees)'.</summary>
public class EmployeeBoardMember: EmployeeManager
{
/// <summary>Gets or sets the CompanyCarId field. Derived from Entity Model Field 'BoardMember.CompanyCarId (FK)'</summary>
public Nullable<System.Int32> CompanyCarId { get; set; }
}
namespace EmployeeManagerTypes
{
/// <summary> Document class which is derived from the entity 'Department (WorksForDepartment.Employees.ManagesDepartment)'.</summary>
public class ManagesDepartment
{
/// <summary>Gets or sets the DepartmentId field. Derived from Entity Model Field 'Department.DepartmentId'</summary>
public System.Int32 DepartmentId { get; set; }
/// <summary>Gets or sets the DepartmentType field. Derived from Entity Model Field 'Department.DepartmentType'</summary>
public System.String DepartmentType { get; set; }
/// <summary>Gets or sets the MeetingRoomCode field. Derived from Entity Model Field 'Department.MeetingRoomCode'</summary>
public System.String MeetingRoomCode { get; set; }
/// <summary>Gets or sets the Name field. Derived from Entity Model Field 'Department.Name'</summary>
public System.String Name { get; set; }
}
}
/// <summary> Document class which is derived from the entity 'Clerk (WorksForDepartment.Employees)'.</summary>
public class EmployeeClerk: Employee
{
/// <summary>Gets or sets the JobDescription field. Derived from Entity Model Field 'Clerk.JobDescription'</summary>
public System.String JobDescription { get; set; }
}
}
}
}
[Test]
public void InsertBoardMember()
{
using(var adapter = new DataAccessAdapter())
{
var metaData = new LinqMetaData(adapter);
var toInsert = metaData.BoardMember.ProjectToBoardMember().ToList();
using(var conn = _connFactory.Get())
{
var db = Query.Db("InheritanceOne");
var table = db.Table<BoardMember>("BoardMember");
conn.Run(table.Insert(toInsert));
}
}
}
{
"companyCar": {
"brand": "Fiat" ,
"carId": 1
} ,
"companyCarId": 1 ,
"id": 4 ,
"managesDepartmentId": 1 ,
"managesDepartmentName": "Marketing Europe" ,
"name": "Boardmember 1" ,
"startDate": Thu Dec 27 2007 15:53:04 GMT+00:00 ,
"worksForDepartment": {
"employees": [
{
"companyCarId": 1 ,
"managesDepartment": null ,
"managesDepartmentId": null ,
"name": null
}
] ,
"name": "Board Europe"
} ,
"worksForDepartmentId": 2
}
[Test]
public void ReadBoardMember()
{
using(var adapter = new DataAccessAdapter())
{
var metaData = new LinqMetaData(adapter);
var ob = metaData.BoardMember.ProjectToBoardMember().FirstOrDefault();
Assert.IsNotNull(ob);
using(var conn = _connFactory.Get())
{
var db = Query.Db("InheritanceOne");
var table = db.Table<BoardMember>("BoardMember");
var b = conn.Run(table.Filter(x=>x.EmployeeId == 4)).FirstOrDefault();
Assert.IsNotNull(b);
Assert.AreEqual(ob.CompanyCarId, b.CompanyCarId);
Assert.AreEqual(ob.ManagesDepartmentId, b.ManagesDepartmentId);
Assert.AreEqual(ob.ManagesDepartmentName, b.ManagesDepartmentName);
Assert.AreEqual(ob.Name, b.Name);
Assert.AreEqual(ob.StartDate, b.StartDate);
Assert.AreEqual(ob.WorksForDepartmentId, b.WorksForDepartmentId);
Assert.AreEqual(ob.CompanyCar.Brand, b.CompanyCar.Brand);
Assert.AreEqual(ob.CompanyCar.CarId, b.CompanyCar.CarId);
Assert.AreEqual(ob.WorksForDepartment.Name, b.WorksForDepartment.Name);
Assert.AreEqual(ob.WorksForDepartment.Employees[0].GetType(), b.WorksForDepartment.Employees[0].GetType());
Assert.AreEqual(((IHMMDocs.RethinkDB.DocumentClasses.BoardMemberTypes.WorksForDepartmentTypes.EmployeeBoardMember)ob.WorksForDepartment.Employees[0]).CompanyCarId,
((IHMMDocs.RethinkDB.DocumentClasses.BoardMemberTypes.WorksForDepartmentTypes.EmployeeBoardMember)b.WorksForDepartment.Employees[0]).CompanyCarId);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment