fluent

EF5 Fluent API byte array to long

ε祈祈猫儿з 提交于 2019-12-12 02:12:06
问题 Using EF5 Fluent API does anyone know if it's possible to have a binary column in the database but a long in the C#? When we put a long in the entity we always end up with EF errors at runtime (unable to perform the mapping). If we put a byte[] then everything works (binary in db usually means byte[] type in .NET code). We can't change database column type so it's not a solution. Here is what we end up doing : from l in LeadDataRepository.GetAll() select new { // we need an anonymous type

Optional One to many relationship

我与影子孤独终老i 提交于 2019-12-12 00:07:00
问题 I am trying to make and optional one to many relationship using fluent API. But it doesn't seem to work as I get this error: InBuildingNavigator.Data.Models.ConnectionPointRoute_Segment: : Multiplicity conflicts with the referential constraint in Role 'ConnectionPointRoute_Segment_Target' in relationship 'ConnectionPointRoute_Segment'. Because all of the properties in the Dependent Role are non-nullable, multiplicity of the Principal Role must be '1'. This is the modelcreation : protected

js method chain tail

北城余情 提交于 2019-12-11 18:41:51
问题 is there a way to detect if a method call in a chain (fluent interface) is in TAIL position in that chain ? var some = g.f(arg1).f(arg2).f(arg3); or do we absolutely need something like var some = g.f(arg1).f(arg2).f(arg3).end(); which I want avoid ? REturned value is not so important for me, but I need to compute something (an internal string-like key) at the end of the chain, with could have different lengths from one call to another. 回答1: No, there is no way to detect if a given method is

Elastic search Nest - map update string property as not analysed

自作多情 提交于 2019-12-11 16:01:01
问题 I'm trying to map MyCode property in my object (posted down) as NotAnalyzed using fluent. I've already reviewed: Creating an index Nest and Nest and Elastic Search - Mapping { "myobject_test" : { "mappings" : { "myversion" : { "properties" : { "id" : { "type" : "long" }, "isLatest" : { "type" : "boolean" }, "maxVersion" : { "type" : "long" }, "original" : { "properties" : { "agent" : { "properties" : { "name" : { "type" : "string" }, "organizationId" : { "type" : "long" }, "version" : { "type

Map List<Int32> using Fluent Nhibernate

蓝咒 提交于 2019-12-11 14:05:06
问题 I need to map List<Int32> using Fluent Nhibernate. Sample code: public class ReportRequest { public List<Int32> EntityIds { get { return entityIds; } set { entityIds = value; } } } Please guide. Thank you! 回答1: I have implemented it as : public class ReportRequestMap : ClassMap<ReportRequest> { public ReportRequestMap() { Id(x => x.Id).UnsavedValue(null).GeneratedBy.Native(); HasMany(x => x.EntityIds).Table("ReportEntities").KeyColumn("ReportRequestId").Element("EntityId").AsBag(); } } 来源:

NHibernate ReferencesAny pulling back the wrong type

我是研究僧i 提交于 2019-12-11 08:08:13
问题 I've got a table called AdministratorPrivilages that has the following fields: ID List item MemberId Value MemberType Now, the members can be of two types (Enterprise and Express). Enterprise members live in the enterprise table. Express members live in the expressmember table. I've tried to do my fluent mapping like so. public class AdministratorPrivilegesMapping : ClassMap<AdministratorPrivileges> { public AdministratorPrivilegesMapping() { Id(x=>x.Id); Map(x => x.Value).Column("Value");

Model class and Mapping

耗尽温柔 提交于 2019-12-11 04:34:25
问题 I have the Client class defined. I also have Mapping\ClientMap.cs file that defines column names using Fluent API. However, I am not sure how to "invoke" it as I don't see the ClientMap.cs code being executed. I also have this: namespace CardNumbers.Data { public class Repository : DbContext, IRepository { public DbSet<Client> Clients { get; set; } public DbSet<ClientOrder> ClientOrders { get; set; } public DbSet<Reorder> Reorders { get; set; } public DbSet<Operator> Operators { get; set; }

EF lazy loading & fluent API creates additional field in table

流过昼夜 提交于 2019-12-11 04:28:53
问题 Here is my code - first, Attachment class: public class Attachment{ (...) public int UserId { get; set; } public virtual User Author { get; set; } public int? BasicMedicalDataId { get; set; } public virtual BasicMedicalData MedicalData { get; set; } } Here is BasicMedicalData class: public class BasicMedicalData{ (..) public virtual ICollection<Attachment> Attachments { get; set; } } As you can see, Attachment can have optionally one connected BasicMedicalData object. BasicMedicalData can

EF Fluent API many to one relation, navigation property is not fetched

*爱你&永不变心* 提交于 2019-12-11 03:48:55
问题 I have a database with the Entity Framework 5 RC (with Fluent API) working now, but I can't seem to get a specific relation to work. And it is driving me nuts for the past few nights I'm working on it. It is the following relation: Link to the database diagram As you can see, I have a Exercise which is related to an ExerciseType . The problem is, the Exercise.ExerciseType navigation property, is not loaded. The relation I made is as follows: EntityTypeConfiguration<Exercise> ... this

Designing fluent builders to create an object graph in C#

谁说我不能喝 提交于 2019-12-10 23:46:54
问题 I am making a first attempt at writing fluent builders in C# so I can simplify the logic for creating object graphs. My first thought was to create a fluent builder for each class, then nest them hierarchically like this: School school = SchoolBuilder.New() .WithName("Whatchamatta U") .AddClass( ClassBuilder.New() .WithName("Arithmetic") .WithClassNumber("101") .AddStudent( StudentBuilder.New() .WithName("John Smith") ) .AddStudent( StudentBuilder.New() .WithName("Jane Smith") ) ) .Save()