FAQ Database Discussion Community


EF Many to Many Inserting Records into Main table as well as join table

entity-framework,code-first,fluent
I have an odd situation with a many to many relationship and inserting data. Table 1 (Region): public class Region { public Region() { SessionList = new List<Session>(); UserProfileList = new List<UserProfile>(); LeagueEventList = new List<LeagueEvent>(); } public int RegionId { get; set; } public string RegionName { get; set;...

One-to-Zero-or-One relationship where the FK is part of a compoun PK on dependent tables

c#,entity-framework,fluent
I'm developing a library with Entity Framework 6.1.2 for these two tables: CREATE TABLE [dbo].[CODES] ( [CODE] [nvarchar](20) NOT NULL, [ ... ], CONSTRAINT [PK_CODES] PRIMARY KEY CLUSTERED ( [CODE] ASC ) ) CREATE TABLE [dbo].[AGGREGATIONS] ( [ID_AGGREGATION] INT IDENTITY(1,1) NOT NULL, [CODE_LEVEL] TINYINT NOT NULL, [CODE] NVARCHAR(20) NOT NULL,...

fluent and webhdfs filename with 197001011

fluent,fluentd,webhdfs
I run td-agent on ubuntu 14.04 with the follow configuration: <source> type tail format json path /path/tomcat/logs/file-input.log tag bhc.hdfs pos_file /var/td-agent/file.pos </source> <match bhc.hdfs> type webhdfs port 50070 host my.host.name path /hdfs/path/file.${hostname}.%Y%m%d.log username user flush_interval 10s output_include_time false output_include_tag false output_data_type json </match> Log source files in directory /path/tomcat/logs/file-input.log contain...

How can I write this so it only hits the database once?

php,mysql,laravel,eloquent,fluent
This is what I currently have: $sortOrder = ['0','1','4','2','3']; $cards = ComboCard::where('username', '=', $user->username) ->where('combo_uid', '=', $comboUid) ->select('id', 'card_order') ->orderBy('card_order', 'ASC') ->get(); for($i=0; $i<count($cards); $i++) { // currently hits the database n times based on count($cards) $index = $sortOrder[$i]; $cards[$index]->card_order = $i; $cards[$index]->save(); } ...

Java - NoHttpResponseException when using apache fluent api to post

java,apache,exception-handling,fluent,http-request
I am continuously posting data to server using Java with Apache fluent api. Content content = Request.Post(URL) .bodyForm(param) .execute() .returnContent(); The above works perfectly but after some random execution time I am getting org.apache.http.NoHttpResponseException: failed to respond. How I can handle this to post the same parameter again after getting...

Id naming convention in Laravel

php,mysql,laravel,eloquent,fluent
In a recent project I had a custom id name for one of my tables, the user table (it was called user_id instead of simply id). When I tried to insert data into it, I got the following error: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'id' in 'where clause'...

Persisting DateTime when saving/updating entities in fluent nhibernate

c#,nhibernate,timestamp,fluent
I'm trying to persist the datetime of creation and update of entites (not relevent to versioning and concurrency) using fluent nhibernate. To achieve this using nhibernate I would write this mapping tag: <timestamp name="Timestamp" access="property" unsaved-value="null" /> How can I make fluent nhiberbate generate that mapping tag?...

Using Laravel Fluent is there a way to retrieve an updated or inserted row?

php,mysql,laravel,fluent
For example I have the following query which updates a new row: $query->where('email', '=', $user->email)->where('card_uid', '=', $k) ->update( array('email' => $user->email, 'card_uid' => $k, 'have_quantity' => ($card->have_quantity+$v)) ); I'd like to retrieve the updated (or inserted) row. I tried the following but it doesn't work: $row = $query->where('email', '=', $user->email)->where('card_uid',...

Fluent Groovy syntax using command chaining and maps

groovy,closures,fluent,method-chaining
Given the following Groovy code: someMap = ['key':{ str -> println "SUCCESS: ${str}" }] clos = { someMap } All of the following are legal ways to print SUCCESS: abc: clos(null)['key'] "abc" clos null key "abc" someMap['key'] "abc" This one, however: someMap key "abc" throws a groovy.lang.MissingPropertyException: No such property:...

Using Laravel Fluent how can I exclude certain rows based on an array of strings?

php,laravel,fluent
In my controller file I have this: $standard_sets = ['A', 'B', 'C', 'D', 'E']; $exclude_list = ['str1', 'str2', 'str3']; I'd like to exclude certain rows based on the exclude array. Something like this: $query->whereIn('cards.setCode', $standard_sets) ->exclude('cards.name', $exclude_list); What is the right way to write this?...

Entity framework fluent mapping many-to-may

c#,entity-framework,mapping,many-to-many,fluent
I'm having a problem when I try to map this model: public class Discipline { public int Id {get;set;} public string Name{get;set;} public virtual ICollection<DisciplineRequirement> Requirements {get;set;} } public class DisciplineRequirement { public int DisciplineId {get;set;} public int RequiredDiscipline {get;set;} public virtual Discipline Discipline {get;set;} public virtual Discipline RequiredDiscipline {get;set;}...