Questions tagged [fluent]

Fluent interface is an API which allows method chaining to make code more readable.

Fluent interface is API which allows method chaining to make code more readable.

1148 questions
375
votes
17 answers

Laravel - Eloquent or Fluent random row

How can I select a random row using Eloquent or Fluent in Laravel framework? I know that by using SQL, you can do order by RAND(). However, I would like to get the random row without doing a count on the number of records prior to the initial…
DigitalWM
  • 4,406
  • 3
  • 18
  • 15
94
votes
9 answers

How to set every row to the same value with Laravel's Eloquent/Fluent?

I need to update all of the rows in a database so that a particular field in all of them is equal to a single value. Here's an example. Let's say my database table is like…
Pete
  • 7,289
  • 10
  • 39
  • 63
80
votes
2 answers

How to select count with Laravel's fluent query builder?

Here is my query using fluent query builder. $query = DB::table('category_issue') ->select('issues.*') ->where('category_id', '=', 1) ->join('issues', 'category_issue.issue_id', '=', 'issues.id') …
Alex Naspo
  • 2,052
  • 1
  • 20
  • 37
64
votes
5 answers

laravel migration re-organising column order

When you create a new column in a table you can use the ->after('column name') to dictate where it goes. How can I create a migration that re-orders the columns in the right order I want?
user391986
  • 29,536
  • 39
  • 126
  • 205
56
votes
10 answers

Creating API that is fluent

How does one go about create an API that is fluent in nature? Is this using extension methods primarily?
mrblah
  • 99,669
  • 140
  • 310
  • 420
41
votes
7 answers

Implementing Zero Or One to Zero Or One relationship in EF Code first by Fluent API

I have two POCO classes: Order Class: public class Order { public int Id { get; set; } public int? QuotationId { get; set; } public virtual Quotation Quotation { get; set; } .... } Quotation Class: public class Quotation { …
Masoud
  • 8,020
  • 12
  • 62
  • 123
33
votes
8 answers

truncate all tables in laravel using eloquent

Is there a way I could truncate all the tables in a db using eloquent or fluent in laravel 4? I do not want to specify table names, I just want to truncate all the tables. In other words empty all the tables.
Mounir
  • 393
  • 1
  • 7
  • 11
33
votes
2 answers

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

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…
inutan
  • 10,558
  • 27
  • 84
  • 126
32
votes
3 answers

Fluent NHibernate, working with interfaces

I just switched to Fluent NHibernate and I've encountered an issue and did not find any information about it. Here's the case : public class Field : DomainObject, IField { public Field() { } public virtual string Name { get; set;…
Charles Ouellet
  • 6,338
  • 3
  • 41
  • 57
31
votes
8 answers

Schema specified is not valid. Errors: The relationship was not loaded because the type is not available

I wish to reference the OrderAddress model twice in my Order model; once as a ShippingAddress and once as a BillingAdress. On the other side, I want my OrderAddress model to have a list of OrderAddresses. OrderAddress Model public enum…
Fred Fickleberry III
  • 2,439
  • 4
  • 34
  • 50
29
votes
1 answer

Set up caching on entities and relationships in Fluent Nhibernate?

Does anyone have an example how to set up and what entities to cache in fluent nhibernate. Both using fluent mapping and auto mapping? And the same for entity relationships, both one-to-many and many-to-many?
Emil C
  • 1,315
  • 4
  • 15
  • 27
27
votes
4 answers

Fluent assertion for OR condition

I am trying to set up the fluent assertion for the below condition. But couldnt find a method with expression or an ObjectAssertion with Or(). I got to check the status of my service is of enum value Pending or…
Raghav
  • 2,890
  • 7
  • 36
  • 56
26
votes
4 answers

Inheritance Mapping with Fluent NHibernate

Given the following scenario, I want map the type hierarchy to the database schema using Fluent NHibernate. I am using NHibernate 2.0 Type Hierarchy public abstract class Item { public virtual int ItemId { get; set; } public virtual string…
Jim
25
votes
3 answers

Laravel Fluent queries - How do I perform a 'SELECT AS' using Fluent?

I have a query to select all the rows from the hire table and display them in a random order. DB::table('hire_bikes')->order_by(\DB::raw('RAND()'))->get(); I now want to be able to put concat(SUBSTRING_INDEX(description, " ",25), "...") AS…
adam Kearsley
  • 951
  • 2
  • 13
  • 23
22
votes
7 answers

How to Design Fluent Async Operations?

Async operations do not seem to play well with fluent interfaces which I prefer to code in. How can Asynchrony be combined with Fluent? Sample: I have two methods that previously returned a MyEntity but do not play well when change to Async. After…
k.c.
  • 1,755
  • 1
  • 29
  • 53
1
2 3
76 77