Fluent interface in Delphi

Everybody is just writing about negative issues so let’s stress some positive issues. Errr, the only positive issue – less (in some cases much less) typing. I wrote GpFluentXMLBuilder just because I hate typing tons of code while creating XML documents. Nothing more and nothing less. The good point with fluent interfaces is that you … Read more

How to store double[] array to database with Entity Framework Code-First approach

You can do a thing like this : [NotMapped] public double[] Data { get { string[] tab = this.InternalData.Split(‘,’); return new double[] { double.Parse(tab[0]), double.Parse(tab[1]) }; } set { this.InternalData = string.Format(“{0},{1}”, value[0], value[1]); } } [EditorBrowsable(EditorBrowsableState.Never)] public string InternalData { get; set; }

Fluent Interfaces – Method Chaining

The core idea behind building a fluent interface is one of readability – someone reading the code should be able to understand what is being achieved without having to dig into the implementation to clarify details. In modern OO languages such as C#, VB.NET and Java, method chaining is one way that this is achieved, … Read more

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

You want to declare T as extends AbstractBuilder<T> in AbstractBuilder. Use an abstract protected method to get this of type T. abstract class AbstractBuilder<T extends AbstractBuilder<T>> { protected abstract T getThis(); public T foo() { // set some property return getThis(); } } class TheBuilder extends AbstractBuilder<TheBuilder> { @Override protected TheBuilder getThis() { return this; … Read more

EF6.0 “The relationship could not be changed because one or more of the foreign-key properties is non-nullable”

You need to delete the ItemTypeItem. It is not possible to just remove it from the Items list as it cannot exist by itself, because it has a non-nullable foreign key referencing ItemType (ItemTypeID). To delete the ItemTypeItem add context.Entry(itemTypeItem).State = EntityState.Deleted;

Creating Unique Index with Entity Framework 6.1 fluent API

NOTE: Relevant to EF 6 You can use IndexAttribute as mentioned but with Fluent API instead of DataAnnotations which will do the trick: modelBuilder .Entity<Person>() .Property(t => t.Name) .HasColumnAnnotation( “Index”, new IndexAnnotation(new IndexAttribute(“IX_Name”) { IsUnique = true })); Unfortunately there is no other way to create unique indexes using Fluent API. There is an open … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)