fluent-interface

BaseFoo cannot be inherited with different arguments: <T,X.Bar<T>> and <T,X.Foo<T>>

走远了吗. 提交于 2019-12-01 10:26:14
This is a simplified version of Java inherited Fluent method return type in multiple level hierarchies . Given the following code: 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 interface BaseBar<T, S extends BaseBar<T, S>> extends BaseFoo<T, S> { S bar(); } static interface Bar<T> extends BaseBar<T, Bar<T>>, Foo<T> { void bar1(); } } run javac X.java I get the error message: X.java:15: error: BaseFoo cannot be inherited with different arguments: <T,X.Bar<T>> and <T,X.Foo<T>> static

BaseFoo cannot be inherited with different arguments: <T,X.Bar<T>> and <T,X.Foo<T>>

风流意气都作罢 提交于 2019-12-01 07:54:49
问题 This is a simplified version of Java inherited Fluent method return type in multiple level hierarchies. Given the following code: 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 interface BaseBar<T, S extends BaseBar<T, S>> extends BaseFoo<T, S> { S bar(); } static interface Bar<T> extends BaseBar<T, Bar<T>>, Foo<T> { void bar1(); } } run javac X.java I get the error message: X.java

EF 4.1 RC: Weird Cascade Delete

妖精的绣舞 提交于 2019-11-30 22:44:19
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 a currency does not need to be assigned to a country at all. If you let EF create the corresponding

The DELETE statement conflicted with the SAME TABLE REFERENCE constraint with Entity Framework

二次信任 提交于 2019-11-30 11:26:47
I have a table with a self reference where the ParentId is an FK to the ID (PK). Using EF (code-first), I've set up my relationship as follows: this.HasOptional(t => t.ParentValue) .WithMany(t => t.ChildValues) .HasForeignKey(t => t.ParentId); When I try to delete the children and its parent, the DELETE commands EF issues to the database are not in the order I expected them to go - it attempts to delete the parent record first. I realize that I have a couple of options here (neither of which I like): Delete child records first, do a full save/commit, and then delete parent record. With the

Code-First Reference one-to-many

孤街醉人 提交于 2019-11-30 10:08:19
I have the following two tables: LOCALIZATION Id int Text string DINER Id int Name string Description string Name_LocalizationID int Description_LocationID int Now I want my POCO like this: public class Diner{ public int Id{get;set;} public ICollection<Localization> NameLocalization{get;set;} public ICollection<Localization> DescriptionLocalization{get;set;} } public class Localization{ public int Id{get;set;} public string Text{get;set;} } Question is: How we can map NameLocalization and DescriptionLocalization property to Localization's Id with EF Fluent API? Thanks SQL Server does not

How to subclass str in Python

牧云@^-^@ 提交于 2019-11-30 03:01:13
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 instance when custom methods modified it. I want to be able to do something like this: a = mystr(

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

懵懂的女人 提交于 2019-11-30 01:42:01
How can I store an array of doubles to database using Entity Framework Code-First with no impact on the existing code and architecture design? I've looked at Data Annotation and Fluent API, I've also considered converting the double array to a string of bytes and store that byte to the database in it own column. I cannot access the public double[] Data { get; set; } property with Fluent API, the error message I then get is: The type double[] must be a non-nullable value type in order to use it as parameter 'T'. The class where Data is stored is successfully stored in the database, and the

The DELETE statement conflicted with the SAME TABLE REFERENCE constraint with Entity Framework

醉酒当歌 提交于 2019-11-29 17:08:20
问题 I have a table with a self reference where the ParentId is an FK to the ID (PK). Using EF (code-first), I've set up my relationship as follows: this.HasOptional(t => t.ParentValue) .WithMany(t => t.ChildValues) .HasForeignKey(t => t.ParentId); When I try to delete the children and its parent, the DELETE commands EF issues to the database are not in the order I expected them to go - it attempts to delete the parent record first. I realize that I have a couple of options here (neither of which

Code-First Reference one-to-many

核能气质少年 提交于 2019-11-29 14:50:25
问题 I have the following two tables: LOCALIZATION Id int Text string DINER Id int Name string Description string Name_LocalizationID int Description_LocationID int Now I want my POCO like this: public class Diner{ public int Id{get;set;} public ICollection<Localization> NameLocalization{get;set;} public ICollection<Localization> DescriptionLocalization{get;set;} } public class Localization{ public int Id{get;set;} public string Text{get;set;} } Question is: How we can map NameLocalization and

What's a fluent interface?

拈花ヽ惹草 提交于 2019-11-29 08:13:46
问题 I recently came across this expression - but reading up on Wikipedia did not clarify it much for me - I still don't get it: What's the point of it How is it used in practice (i.e. how does it benefit a coder in their day to day work/building systems)? [Edit] The Wikipedia article C++ example is overly long, and conflates the discussion of a fluent interface with an example of a simple Glut app. Can someone provide a SUCCINCT C++ example of a class that illustrates a fluent interface (how does