fluent-interface

How do I map a char property using the Entity Framework 4.1 “code only” fluent API?

混江龙づ霸主 提交于 2019-11-27 14:16:09
I have an object that has a char property: public class Product { public char Code { get; set; } } Entity Framework doesn't seem to be able to map chars (this field is missing from the database when I create the database schema from my model objects). Is there anyway I can map the char (e.g. to a string) using the fluent API? I don't want to change the model objects as they are part of a legacy shared library. Ladislav Mrnka Char is not valid primitive type for entity framework = entity framework doesn't map it. If you check CSDL reference you will see list of valid types ( char is not among

How to create a fluent query interface?

最后都变了- 提交于 2019-11-27 13:19:11
I know how to chain class methods (with the "return $this" and all), but what i am trying to do is to chain them in a smart way, have a look at this: $albums = $db->select('albums')->where('x', '>', '20')->limit(2)->order('desc'); What i could understand from this code sample is that the first 3 methods (select, where, limit) build the query statement that will be executed, and the last one (order) comes to finish the statement and then executes it and throws back the result, right ? But, this isn't the case, because i can easily drop any of these methods (except "select" of course) or - more

Designing a fluent Javascript interface to abstract away the asynchronous nature of AJAX

倖福魔咒の 提交于 2019-11-27 11:29:48
How would I design an API to hide the asynchronous nature of AJAX and HTTP requests, or basically delay it to provide a fluent interface. To show an example from Twitter's new Anywhere API: // get @ded's first 20 statuses, filter only the tweets that // mention photography, and render each into an HTML element T.User.find('ded').timeline().first(20).filter(filterer).each(function(status) { $('div#tweets').append('<p>' + status.text + '</p>'); }); function filterer(status) { return status.text.match(/photography/); } vs this (asynchronous nature of each call is clearly visible) T.User.find('ded

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

眉间皱痕 提交于 2019-11-27 07:15:19
If I try to delete a "child" row I always get an exception. Here is a snipset: using (var context = new CompanyContext()) { ItemType itemType = context.ItemTypes.FirstOrDefault(i => i.Name == "ServerType"); ItemTypeItem itemTypeItem = itemType.Items.FirstOrDefault(i => i.Name == "DatabaseServer"); itemType.Items.Remove(itemTypeItem); context.SaveChanges(); <=== exception! } The following exception is thrown on the SaveChanges() method. "The relationship could not be changed because one or more of the foreign-key properties is non-nullable. When a change is made to a relationship, the related

Entity Framework Code First Case Sensitivity on string PK/FK Relationships

感情迁移 提交于 2019-11-27 06:47:59
问题 I have a fairly simple composite one to many relationship defined using POCO/Fluent API, one column of which is a string. I've discovered that the data in this column in our database is inconsistent in terms of case ie 'abb', 'ABB' - this is our main ERP system and is fed by a variety of sources which are mainly beyond our control. This is leading to problems using EF code first when joining to related tables as the join is silently ignored by EF when the case of PK/FK is different even

Fluent interfaces and inheritance in C#

早过忘川 提交于 2019-11-27 06:27:03
I'll show a problem by example. There is a base class with fluent interface: class FluentPerson { private string _FirstName = String.Empty; private string _LastName = String.Empty; public FluentPerson WithFirstName(string firstName) { _FirstName = firstName; return this; } public FluentPerson WithLastName(string lastName) { _LastName = lastName; return this; } public override string ToString() { return String.Format("First name: {0} last name: {1}", _FirstName, _LastName); } } and a child class: class FluentCustomer : FluentPerson { private long _Id; private string _AccountNumber = String

Entity Framework Code First Fluent Api: Adding Indexes to columns

拟墨画扇 提交于 2019-11-27 05:58:21
I'm running EF 4.2 CF and want to create indexes on certain columns in my POCO objects. As an example lets say we have this employee class: public class Employee { public int EmployeeID { get; set; } public string EmployeeCode { get; set; } public string FirstName { get; set; } public string LastName { get; set; } public DateTime HireDate { get; set; } } We often do searches for employees by their EmployeeCode and since there are a lot of employees it would be nice to have that indexed for performance reasons. Can we do this with fluent api somehow? or perhaps data annotations? I know it is

Creating Unique Index with Entity Framework 6.1 fluent API

耗尽温柔 提交于 2019-11-27 05:42:29
问题 I have a column "Name" that must be unqiue. No foreign key or anything like that. EF 6.1 finally supports creating such indexes via Annotations. That has been discussed already on SO. But it seems it can only be done via annotations in the classes. How do I do that using only the Fluent API? Something like this: public class PersonConfiguration : EntityTypeConfiguration<Person> { public PersonConfiguration() { HasKey(p => p.Id); Property(p => p.Id).HasDatabaseGeneratedOption

How to do a PHP nested class or nested methods?

南笙酒味 提交于 2019-11-27 05:41:14
问题 How can I do this in PHP $myDBClass->users()->limit(5);//output you limited users to 5 $myDBClass->comments()->limit(3);//output you limited comments to 3 what I meant is nested methods or nested class (I don't know!) so when I call the limit method as a child of users it will know that I am calling it from "users" method -or class- and when I call limit method -or class!- from comments It also knows that. what is the possible structure for a PHP class to do this thing? the reason for this

101 tutorial for setting up nhibernate? [closed]

女生的网名这么多〃 提交于 2019-11-27 05:04:41
问题 I am looking for a tutorial on setting up nhibernate. There seems to be few out there, but most are either written in gibberish, or are on an extremely ancient release. Any good resources, possibly even the inclusion of fluent or a code configured install? 回答1: if you're interested in screencasts, checkout the summer of nhibernate tutorials. They're an execllent way to get up and running 回答2: The NHibernate FAQ has everything you need (from blog post 1, that is) including step-by-step