This question is locked. New answers and comments are not allowed.
I'm still in the architect stage of my app and I have decided to use OA. However I can't quite get my mind around using objects/classes when it comes to querying and creating my interfaces.
Basically I get stuck at this point. I have 2 reversed mapped classes, an interface, and a DataService class that I have listed below. The classes osParticipant and osEntitiy are related, along with a bazillion other tables, to one another. The problem I have is how to construct my interface to say that I am going to return a generic list containing objects or classes that contain fields from both of the related classes?
I can see where doing a simple IList<osEntity> or a IList<osParticipant> would be easy, but how do I do a IList<osEntity + osParticipant>? I read a thread on the forums where it was said that if tables are related a property would be mapped to the related class and a query such as this:
would be possible, however I am not seeing a property in any of the classes that were created and if this does work how would you return a collection of the result. I mean what type would be in the Collection?
Also to expand the question, the osParticipant table has related tables such as an Address table that is a one to many relation. How would doing a query such as the one above handle this scenario? I am assume a property in osParticipant would be a collection that would hold the many addresses, but I do not see that being the case in any of the classes that OA generated.
Anyhow as you can see I am throughly confused at this point and any help you could offer would be greatly appreciated. I think if you could offer a quick sample/example then a light bulb will go off and I can have one of thos aha moments!
I went through the OA Examples that come with it, but to tell you the truth I had a hard time pulling out what I was looking for. I looked like some queries to the OrderDetails was done in the DBManager class, but then there were a ton of other releated persistent classes that I could not see you pulling from at all.
Thanks in advance!
osParticipant
osEntity
IEliteDataService
EliteDataService
Basically I get stuck at this point. I have 2 reversed mapped classes, an interface, and a DataService class that I have listed below. The classes osParticipant and osEntitiy are related, along with a bazillion other tables, to one another. The problem I have is how to construct my interface to say that I am going to return a generic list containing objects or classes that contain fields from both of the related classes?
I can see where doing a simple IList<osEntity> or a IList<osParticipant> would be easy, but how do I do a IList<osEntity + osParticipant>? I read a thread on the forums where it was said that if tables are related a property would be mapped to the related class and a query such as this:
var query = from userData in scope.Extent<OsEntity>() |
select new |
{ |
ID = userData.EntityID, |
LastName = userdata.LastName, |
FirstName = userdata.FirstName, |
IsActive = userdata.OSParticipant.IsActive |
}; |
Also to expand the question, the osParticipant table has related tables such as an Address table that is a one to many relation. How would doing a query such as the one above handle this scenario? I am assume a property in osParticipant would be a collection that would hold the many addresses, but I do not see that being the case in any of the classes that OA generated.
Anyhow as you can see I am throughly confused at this point and any help you could offer would be greatly appreciated. I think if you could offer a quick sample/example then a light bulb will go off and I can have one of thos aha moments!
I went through the OA Examples that come with it, but to tell you the truth I had a hard time pulling out what I was looking for. I looked like some queries to the OrderDetails was done in the DBManager class, but then there were a ton of other releated persistent classes that I could not see you pulling from at all.
Thanks in advance!
osParticipant
using System; |
using System.Collections.Generic; |
namespace EliteExtender.Infrastructure.Models.Elite |
{ |
// Generated by Telerik OpenAccess |
// Used template: c:\program files (x86)\telerik\openaccess orm\sdk\IDEIntegrations\templates\PCClassGeneration\cs\templates\classgen\class\partialuserdefault.vm |
// NOTE: Field declarations and 'Object ID' class implementation are added to the 'designer' file. |
// Changes made to the 'designer' file will be overwritten by the wizard. |
public partial class OsParticipant |
{ |
//The 'no-args' constructor required by OpenAccess. |
public OsParticipant() |
{ |
} |
[Telerik.OpenAccess.FieldAlias("pk")] |
public int Pk |
{ |
get { return pk; } |
set { this.pk = value; } |
} |
[Telerik.OpenAccess.FieldAlias("creationDate")] |
public DateTime? CreationDate |
{ |
get { return creationDate; } |
set { this.creationDate = value; } |
} |
[Telerik.OpenAccess.FieldAlias("fkMLSosEntityModuleRole")] |
public int FkMLSosEntityModuleRole |
{ |
get { return fkMLSosEntityModuleRole; } |
set { this.fkMLSosEntityModuleRole = value; } |
} |
[Telerik.OpenAccess.FieldAlias("fkosCompanyModule")] |
public int FkosCompanyModule |
{ |
get { return fkosCompanyModule; } |
set { this.fkosCompanyModule = value; } |
} |
[Telerik.OpenAccess.FieldAlias("fkosEntity")] |
public int FkosEntity |
{ |
get { return fkosEntity; } |
set { this.fkosEntity = value; } |
} |
[Telerik.OpenAccess.FieldAlias("fkosEntityModuleSubRole")] |
public int? FkosEntityModuleSubRole |
{ |
get { return fkosEntityModuleSubRole; } |
set { this.fkosEntityModuleSubRole = value; } |
} |
[Telerik.OpenAccess.FieldAlias("isActive")] |
public string IsActive |
{ |
get { return isActive; } |
set { this.isActive = value; } |
} |
[Telerik.OpenAccess.FieldAlias("lastEditDate")] |
public DateTime? LastEditDate |
{ |
get { return lastEditDate; } |
set { this.lastEditDate = value; } |
} |
} |
} |
osEntity
using System; |
using System.Collections.Generic; |
namespace EliteExtender.Infrastructure.Models.Elite |
{ |
// Generated by Telerik OpenAccess |
// Used template: c:\program files (x86)\telerik\openaccess orm\sdk\IDEIntegrations\templates\PCClassGeneration\cs\templates\classgen\class\partialuserdefault.vm |
// NOTE: Field declarations and 'Object ID' class implementation are added to the 'designer' file. |
// Changes made to the 'designer' file will be overwritten by the wizard. |
public partial class OsEntity |
{ |
//The 'no-args' constructor required by OpenAccess. |
public OsEntity() |
{ |
} |
[Telerik.OpenAccess.FieldAlias("pk")] |
public int Pk |
{ |
get { return pk; } |
set { this.pk = value; } |
} |
[Telerik.OpenAccess.FieldAlias("creationDate")] |
public DateTime? CreationDate |
{ |
get { return creationDate; } |
set { this.creationDate = value; } |
} |
[Telerik.OpenAccess.FieldAlias("disguisedTaxID")] |
public string DisguisedTaxID |
{ |
get { return disguisedTaxID; } |
set { this.disguisedTaxID = value; } |
} |
[Telerik.OpenAccess.FieldAlias("entityID")] |
public string EntityID |
{ |
get { return entityID; } |
set { this.entityID = value; } |
} |
[Telerik.OpenAccess.FieldAlias("externalVendorNumber")] |
public string ExternalVendorNumber |
{ |
get { return externalVendorNumber; } |
set { this.externalVendorNumber = value; } |
} |
[Telerik.OpenAccess.FieldAlias("fileNameAs")] |
public string FileNameAs |
{ |
get { return fileNameAs; } |
set { this.fileNameAs = value; } |
} |
[Telerik.OpenAccess.FieldAlias("firstName")] |
public string FirstName |
{ |
get { return firstName; } |
set { this.firstName = value; } |
} |
[Telerik.OpenAccess.FieldAlias("fkosProgramAffiliation")] |
public int? FkosProgramAffiliation |
{ |
get { return fkosProgramAffiliation; } |
set { this.fkosProgramAffiliation = value; } |
} |
[Telerik.OpenAccess.FieldAlias("fullName")] |
public string FullName |
{ |
get { return fullName; } |
set { this.fullName = value; } |
} |
[Telerik.OpenAccess.FieldAlias("initials")] |
public string Initials |
{ |
get { return initials; } |
set { this.initials = value; } |
} |
[Telerik.OpenAccess.FieldAlias("isCompany")] |
public string IsCompany |
{ |
get { return isCompany; } |
set { this.isCompany = value; } |
} |
[Telerik.OpenAccess.FieldAlias("isExcludedFrom1099")] |
public string IsExcludedFrom1099 |
{ |
get { return isExcludedFrom1099; } |
set { this.isExcludedFrom1099 = value; } |
} |
[Telerik.OpenAccess.FieldAlias("isExcludedFromIncomeTargeting")] |
public string IsExcludedFromIncomeTargeting |
{ |
get { return isExcludedFromIncomeTargeting; } |
set { this.isExcludedFromIncomeTargeting = value; } |
} |
[Telerik.OpenAccess.FieldAlias("isSocialSecurityNumber")] |
public string IsSocialSecurityNumber |
{ |
get { return isSocialSecurityNumber; } |
set { this.isSocialSecurityNumber = value; } |
} |
[Telerik.OpenAccess.FieldAlias("isValidated")] |
public string IsValidated |
{ |
get { return isValidated; } |
set { this.isValidated = value; } |
} |
[Telerik.OpenAccess.FieldAlias("lastEditDate")] |
public DateTime? LastEditDate |
{ |
get { return lastEditDate; } |
set { this.lastEditDate = value; } |
} |
[Telerik.OpenAccess.FieldAlias("lastName")] |
public string LastName |
{ |
get { return lastName; } |
set { this.lastName = value; } |
} |
[Telerik.OpenAccess.FieldAlias("lkosAddress1099Override")] |
public int? LkosAddress1099Override |
{ |
get { return lkosAddress1099Override; } |
set { this.lkosAddress1099Override = value; } |
} |
[Telerik.OpenAccess.FieldAlias("lkosAddressDefault")] |
public int? LkosAddressDefault |
{ |
get { return lkosAddressDefault; } |
set { this.lkosAddressDefault = value; } |
} |
[Telerik.OpenAccess.FieldAlias("lkosContactDefault")] |
public int? LkosContactDefault |
{ |
get { return lkosContactDefault; } |
set { this.lkosContactDefault = value; } |
} |
[Telerik.OpenAccess.FieldAlias("middleName")] |
public string MiddleName |
{ |
get { return middleName; } |
set { this.middleName = value; } |
} |
[Telerik.OpenAccess.FieldAlias("namePrefix")] |
public string NamePrefix |
{ |
get { return namePrefix; } |
set { this.namePrefix = value; } |
} |
[Telerik.OpenAccess.FieldAlias("nameSuffix")] |
public string NameSuffix |
{ |
get { return nameSuffix; } |
set { this.nameSuffix = value; } |
} |
[Telerik.OpenAccess.FieldAlias("pHACode")] |
public string PHACode |
{ |
get { return pHACode; } |
set { this.pHACode = value; } |
} |
[Telerik.OpenAccess.FieldAlias("payeeTaxKey")] |
public string PayeeTaxKey |
{ |
get { return payeeTaxKey; } |
set { this.payeeTaxKey = value; } |
} |
[Telerik.OpenAccess.FieldAlias("previousEntityID")] |
public string PreviousEntityID |
{ |
get { return previousEntityID; } |
set { this.previousEntityID = value; } |
} |
[Telerik.OpenAccess.FieldAlias("programAffiliation")] |
public string ProgramAffiliation |
{ |
get { return programAffiliation; } |
set { this.programAffiliation = value; } |
} |
[Telerik.OpenAccess.FieldAlias("taxID")] |
public string TaxID |
{ |
get { return taxID; } |
set { this.taxID = value; } |
} |
} |
} |
IEliteDataService
using System; |
using System.Collections.Generic; |
using System.Linq; |
using System.Text; |
using EliteExtender.Infrastructure.Models.Elite; |
namespace EliteExtender.Infrastructure.Services |
{ |
public interface IEliteService |
{ |
/// <summary> |
/// Returns a list of residents based off a simple search looking only at Tax ID(SSN) or FileNameAs(LastName) |
/// </summary> |
/// <param name="param"></param> |
/// <returns>Returns a List</returns> |
IList<object> SimpleResidentSearch(string param); |
} |
} |
EliteDataService
using System; |
using System.Collections.Generic; |
using System.Linq; |
using System.Text; |
using EliteExtender.Infrastructure.Models.Elite; |
namespace EliteExtender.Infrastructure.Services |
{ |
public class EliteDataService : IEliteService |
{ |
private EliteDBManager dbManager; |
public EliteDataService() |
{ |
dbManager = new EliteDBManager(); |
dbManager.InitializeDatabase(); |
} |
#region IEliteService Members |
public IList<object> SimpleResidentSearch(string param) |
{ |
//var query = from userdata in scope.Extent<osEntity>() |
// select new { |
// ID = userdata.User.ID, |
// LastName = userdata.User.LastName, |
// FirstName = userdata.User.FirstName, |
// LastLogin = userdata.LastLogin |
// }; |
return null; |
} |
#endregion |
} |
} |