fluent-interface

Inheritance EF Code-First

蓝咒 提交于 2019-12-21 04:08:15
问题 I have a base object that I dont want to be mapped in DB as an entity, I only want the properties to be added to the object that is mapped in the DB : Not mapped object (dont know if it matters but baseobject is in another assembly): public class BaseObject { public virtual string Prop1 { get; set; } public virtual string Prop2 { get; set; } } Mapped object: public class ChildObject : BaseObject { public virtual string Prop3 { get; set; } public virtual string Prop4 { get; set; } public

Can I have an abstract builder class in java with method chaining without doing unsafe operations?

帅比萌擦擦* 提交于 2019-12-20 08:58:01
问题 I'm trying to have an abstract base class for some builder classes so I can easily reuse code between the Builder implementations. I want my builders to support method chaining therefore a method has to return "this" instance of the most specific type. I figured I could probably do this with generics. Unfortunatly I did not manage to do it without using unsafe operations. Is it possible? Sample code of how I'm trying it (and how it works) below. I'd like to avoid casting to T in "foo()"

How to read Custom Attributes using reflection set by Fluent API in EF 4.1

一个人想着一个人 提交于 2019-12-20 04:37:27
问题 I've managed to read custom attributes when I use data annotation. like following code. Object[] test = propertyInfo.GetCustomAttributes(typeof(KeyAttribute), true); But when I changed to use Fluent API. I couldn't read that attribute anymore. Any idea? 回答1: Fluent API does not set attributes. Fluent API and Attributes tell EF how to build the model. These are two different ways to achieve the same thing. That is to build the Model. Edit If you need to retrieve the metadata such as primary

Java inherited Fluent method return type in multiple level hierarchies

旧时模样 提交于 2019-12-20 03:13:41
问题 So following the solution described in Java - Inherited Fluent method return type to return incident class' type, not parent's. I want to extend it to multiple levels. The solution works in one level obviously. Here is compiled and runnable code (no dependencies): public enum X { ; static interface BaseFoo<T, S extends BaseFoo<T, S>> { S foo(); } static interface Foo<T> extends BaseFoo<T, Foo<T>> { void foo1(); } static abstract class AbstractFooBase<T, S extends BaseFoo<T, S>> implements

EF 4.1 RC: Weird Cascade Delete

蹲街弑〆低调 提交于 2019-12-19 03:39:17
问题 I have to admit, the features of EF 4.1 RC Codefirst, DataAnnotations and FluentAPI are still overwhelming to me. Sometimes I really don't know what I am doing ;-) Please see the following POCOs: public class Country { [Key] public Guid ID { get; set; } [Required] public virtual Currency Currency { get; set; } } public class Currency { [Key] public Guid ID { get; set; } public virtual ICollection<Country> Countries { get; set; } } The general idea: Every country needs to have a currency. But

EF Code First: Many-to-many and one-to-many

主宰稳场 提交于 2019-12-18 16:48:48
问题 This is probably just because my knowledge with the EF Code First fluent API is lacking, but I'm stumped. I want to model the following: A Groups collection with Id and Name A Users collection with Id and Name Each user is assigned to exactly one primary group Each user may have zero or many secondary groups The table structure I'm going for would look like: Groups Id Name Users Id Name PrimaryGroupId SecondaryGroupAssignments UserId GroupId I've been beating my head against a wall trying to

How to subclass str in Python

☆樱花仙子☆ 提交于 2019-12-18 11:19:19
问题 I am trying to subclass str object, and add couple of methods to it. My main purpose is to learn how to do it. Where I am stuck is, am I supposed to subclass string in a metaclass, and create my class with that meta, or subclass str directly? And also, I guess I need to implement __new__() somehow, because, my custom methods will modify my string object, and will return new mystr obj. My class's methods, should be completely chainable with str methods, and should always return a new my class

How to subclass str in Python

无人久伴 提交于 2019-12-18 11:19:03
问题 I am trying to subclass str object, and add couple of methods to it. My main purpose is to learn how to do it. Where I am stuck is, am I supposed to subclass string in a metaclass, and create my class with that meta, or subclass str directly? And also, I guess I need to implement __new__() somehow, because, my custom methods will modify my string object, and will return new mystr obj. My class's methods, should be completely chainable with str methods, and should always return a new my class

Castle Windsor: Auto-register types from one assembly that implement interfaces from another

痞子三分冷 提交于 2019-12-18 00:31:47
问题 I use Castle Windsor as my IoC container. I have an application that has a structure similar to the following: MyApp.Services.dll IEmployeeService IContractHoursService ... MyApp.ServicesImpl.dll EmployeeService : MyApp.Services.IEmployeeService ContractHoursService : MyApp.Services.IContractHoursService ... I use the XML configuration at the moment, and every time I add a new IService/Service pair, I have to add a new component to the XML configuration file. I want to switch all this over to

Castle Windsor: Auto-register types from one assembly that implement interfaces from another

只愿长相守 提交于 2019-12-18 00:31:40
问题 I use Castle Windsor as my IoC container. I have an application that has a structure similar to the following: MyApp.Services.dll IEmployeeService IContractHoursService ... MyApp.ServicesImpl.dll EmployeeService : MyApp.Services.IEmployeeService ContractHoursService : MyApp.Services.IContractHoursService ... I use the XML configuration at the moment, and every time I add a new IService/Service pair, I have to add a new component to the XML configuration file. I want to switch all this over to