fluent

Entity Framework 4.2: Multiple entities using the same many-to-many relationships

末鹿安然 提交于 2019-12-13 18:04:48
问题 I have a table Travelers : CREATE TABLE [dbo].[Travelers]( [TravelerId] [int] IDENTITY(1,1) NOT NULL, [FirstName] [nvarchar](25) NULL, [LastName] [nvarchar](50) NULL a table Transporters and a join table TransporterTravelers CREATE TABLE [dbo].[TransporterTravelers]( [Transporter_TransporterId] [int] NOT NULL, [Traveler_TravelerId] [int] NOT NULL, to create a many-to-many relationship between travelers and transporters. I used POCO classes to create the entities Traveler and Transporter, and

Laravel 4 - Is it possible to extend the DB class?

烈酒焚心 提交于 2019-12-13 03:44:07
问题 *Note this is a question regarding Laravel 4, not Laravel 3 (which uses Fluent) Is it possible to extend the DB class in Laravel 4? I've tried something as simple as this: class Content extends DB {} With this in my route: print_r(Content::table('content')->get()); And it seems to work as far as using "Content" like "DB". But if I try and set the table name by default similar to how you would in Eloqeunt and use functions such as where or join I get an error like so: print_r(Content::where(

Fluent Nhibernate Oracle Identifier Too Long - Alias Name Issue

倾然丶 夕夏残阳落幕 提交于 2019-12-12 20:28:32
问题 I've tried to do that. HasManyToMany<YechidotDoarInGroup>(x => x.Col_yig) .Table("PigToYig") .ChildKeyColumn("YIG_GROUP_RECID") .ParentKeyColumn("PIG_GROUP_RECID"); but I've got: ORA-00942: table or view does not exist I am trying to establish HasManyToMany connection not by ID , but by some other property . First I've got - too long message. When I've tried to enter my own Table name as an alias , it's not recognized. What should I do? 回答1: Define Table() method before all of your mapping

C++ Builder pattern with Fluent interface

不羁岁月 提交于 2019-12-12 14:10:10
问题 I am trying to implement builder pattern with fluent interface for building the objects in C++. I want the builder to follow CRTP pattern. In Java, I would do something similar to the below code. How do I do the same in C++? The below is some java code that has a base class and a derived class. The derived class's builder inherits the base class's builder.. // Base class public abstract class BaseClass { private final int base_class_variable; BaseClass(final Builder <?> builder) { this.base

Do [DataType(DataType.EmailAddress)] have a counter part in fluent api?

邮差的信 提交于 2019-12-12 13:58:32
问题 If not mistaken, the counter part of DataAnnotation of [DataType(DataType.Currency)] in Fluent api is modelBuilder.Entity<T>.Property(i => i.Price).HasColumnType("Currency") . Then what is the counter part of [DataType(DataType.EmaillAddress)] ? Or is there a site that has a list of if-you-can-do-in-data-annotation-you-can-do-it-in-fluent-api. Because I want to do the validation and mapping using Fluent Api. Thanks 回答1: This is a notoriously confusing area. About your examples: A property

why when i want use EF Power tools for view my model i get error?

天涯浪子 提交于 2019-12-12 12:51:40
问题 Im using EF Code first and i generate my model by "EF 4.x DbContext Fluent Generator for c#" extension in vs2010. but when i want to view my Entity model via EF Power tools i get this error:"Sequence Contains no matching element". is there any idea? 回答1: It's a bit too late and not sure if this would help but for others and historic reasons... I had the same issue (with Beta 3 - and .NET 4/2010/EF5 etc.) - the solution was relatively simple. I just moved out the project from the 'solution

Fluent NHibernate mappings for localization

我与影子孤独终老i 提交于 2019-12-12 10:10:01
问题 I am trying to build a Database from NHibernate mappings and have run into a problem. I have many classes with localized string values: public class MyClass1 { public virtual int Id { get; set; } public virtual ShortString Name { get; set; } public virtual LongString Description { get; set; } } public class MyClass2 { public virtual int Id { get; set; } public virtual ShortString Name { get; set; } public virtual LongString Description { get; set; } } and Languages like public class Language

Best way to store enum values in database - String or Int

痴心易碎 提交于 2019-12-12 07:42:14
问题 I have a number of enums in my application which are used as property type in some classes. What is the best way to store these values in database, as String or Int? FYI, I will also be mapping these attribute types using fluent Nhibernate. Sample code: public enum ReportOutputFormat { DOCX, PDF, HTML } public enum ReportOutputMethod { Save, Email, SaveAndEmail } public class ReportRequest { public Int32 TemplateId { get { return templateId; } set { templateId = value; } } public

Fluent Nhibernate System.ApplicationException : For property 'Id' expected '1' of type 'System.Int32' but got '2' of type 'System.Int32'

丶灬走出姿态 提交于 2019-12-12 04:26:31
问题 Hi I am writing unit tests for fluent Nhibernate, when I run the test in isloation it passes, but when I run multiple tests. or run the test more than once it starts failing with the message below System.ApplicationException : For property 'Id' expected '1' of type 'System.Int32' but got '2' of type 'System.Int32' [TextFixture] public void Can_Correctly_Map_Entity() { new PersistenceSpecification<UserProfile>(Session) .CheckProperty(c => c.Id, 1) .CheckProperty(c => c.UserName, "user")

Nhibernate not inserting parentid into child

百般思念 提交于 2019-12-12 03:23:09
问题 I have a weird problem at hand. First have a look at my table schema. A(ID) B(ID,AID) C(ID,AID) D(ID,CID) The map files are as below: MAP A { HasMany(x => x.B).Cascade.AllDeleteOrphan().Inverse().KeyColumn("AID"); HasMany(x => x.C).Cascade.AllDeleteOrphan().Inverse().KeyColumn("AID"); } MAP B { References(x => x.A).Column("AID"); } MAP C { References(x => x.A).Column("AID"); HasMany(x => x.D).Cascade.AllDeleteOrphan().Inverse().KeyColumn("BID"); } MAP D { References(x => x.C).Column("CID"); }