fluent

How to make update query with parameters and CASE statement in Laravel 4

送分小仙女□ 提交于 2019-12-06 06:39:49
I'm trying to create mysql UPDATE query that will take parameters. In addition I want to append to the end of the field if the field isnt empty. For that I'm using CASE statement. Here's my query in doctrine (from silex): $query = "UPDATE table SET filed = ( CASE WHEN field = '' THEN :param1 ELSE concat(field, :param1) END) WHERE id=:param2"; $app['db']['test_db']->executeUpdate($sql, array('param1' => $user_text, 'param2' => $selected_id)); Now I want to convert it to fluent or raw query so I can use it in Laravel 4. Here's my code: $param1 = "String..."; // user string $param2 = 45; // id DB

How to ship logs from pods on Kubernetes running on top of GCP to elasticsearch/logstash?

穿精又带淫゛_ 提交于 2019-12-06 02:07:49
问题 I run new modules of my system in Google-Container-Engine. I would like to bring stdout and stderr from them (running in pods) to my centralised logstash. Is there an easy way to forward logs from pods to external logging service, e.g., logstash or elasticsearch? 回答1: I decided to log directly to elasticsearch , an external virtual machine that can be access at elasticsearch.c.my-project.internal (I am on Google-Cloud-Platform). It is quite easy: Setup an ExternalService with name:

Fluent NHibernate IDictionary with composite element mapping

折月煮酒 提交于 2019-12-06 01:56:10
i have these 2 classes: public class Category { IDictionary<string, CategoryResorce> _resources; } public class CategoryResource { public virtual string Name { get; set; } public virtual string Description { get; set; } } and this is xml mapping <class name="Category" table="Categories"> <id name="ID"> <generator class="identity"/> </id> <map name="Resources" table="CategoriesResources" lazy="false"> <key column="EntityID" /> <index column="LangCode" type="string"/> <composite-element class="Aca3.Models.Resources.CategoryResource"> <property name="Name" column="Name" /> <property name=

I get an error in my first (fluent) nhibernate query Initializing[type]-failed… no session or session was closed

若如初见. 提交于 2019-12-05 19:38:52
I just started with NHibernate, created my mappings using fluent NHibernate as follows: public class CustomerMap : ClassMap<Customer> { public CustomerMap() { Id(x => x._id, "Id"); Map(x => x._KdNr, "KdNr"); Map(x => x._Name, "Name"); HasMany(x => x._Contact) .Table("Contacts") .KeyColumn("FKCustomerID") .LazyLoad(); } } public class ContactMap : ClassMap<Contact> { public ContactMap() { Id(x => x._id, "Id"); Map(x => x._Name, "Name"); } } And to save new records works also: public static void AddCustomer(Customer cust) { using (var session = SessionFactory.Instance.OpenSession()) { session

EntityFrameworkCore 中实体的几种配置方法

无人久伴 提交于 2019-12-05 15:04:04
使用数据注解 实体类通常是在 Models 目录下,直接在实体类上添加属性注解,比如 [Required]/[Key] 等. using System.ComponentModel.DataAnnotations; public class User() { [Key] public string UserId { get; set; } [Required] public string UserName { get; set; } } 重写配置方法 在自己实现的 XxxDbContext 数据库上下文类中重写配置方法,用 Fluent API 的方式添加所有实体的配置. using Microsoft.EntityFrameworkCore; public partial class XxxDbContext : DbContext { public XxxDbContext() { } public HaoyikuDbContext(DbContextOptions<HaoyikuDbContext> options) : base(options) { } public DbSet<User> Users { get; set; } // 重写以下方法 protected override void OnModelCreating(ModelBuilder

Fluent NHibernate: Prevent class from being mapped

前提是你 提交于 2019-12-05 13:40:45
I am sure it is a piece of cake, but I can't find it using google. I need to EXCLUDE a single class from mapping. My current configuration is: return Fluently.Configure() .Database(MsSqlConfiguration.MsSql2005.ConnectionString(c => c.Is(@"Data Source=PC\SQLEXPRESS;......"))) .Mappings(m => m.AutoMappings.Add( AutoPersistenceModel.MapEntitiesFromAssemblyOf<Person2>() .Where(t => t.Namespace == "ExampleData.HumansTest") .UseOverridesFromAssemblyOf<PersonMappingOverrides>() .ConventionDiscovery.AddFromAssemblyOf<PersonMappingOverrides>() ) ).BuildConfiguration(); Works nice, so far... But I have

EF Composite key fluent API

笑着哭i 提交于 2019-12-05 10:27:21
I am trying to map a composite key for an entity. public class Customer { public int CustomerId { get; set; } public virtual List<CustomerImage> CustomerImages { get; set; } } And its Map: public class CustomerMap : EntityTypeConfiguration<Customer> { public CustomerMap() { HasKey(t => t.CustomerId); ToTable(DbConstants.k_CustomersImageTable); } } An Image: public class Image { public int ImageId { get; set; } } And its map: public class ImageMap : EntityTypeConfiguration<Image> { public ImageMap() { HasKey(t => t.ImageId); ToTable(DbConstants.k_ImagesTable); } } And the navigation property:

Fluent NHibernate: Mixing Automapping and manual mapping

廉价感情. 提交于 2019-12-05 04:15:56
If using Fluent NHibernate, is it possible to automap most classes, but specify that a couple of particular classes should be mapped using the regular fluent API rather than being automapped? And if so, can anyone point me to some sample code that shows how to do it? Thanks! It is possible and easy to mix-up mapping configurations: var cfg = Fluently.Configure() .Database(configurer) .Mappings(map => { // Automapping map.AutoMappings.Add(AutoMap.Assemblies(Assembly.GetExecutingAssembly()) .Where(type => type == typeof(Domain.Market.Share)) .Where(type => type == typeof(Domain.HR.Employee))); /

Fluent NHibernate fetching view without unique identifier

戏子无情 提交于 2019-12-05 00:15:17
I'm trying to map a view without an identifier, but nhibernate still generates a sql with the id column (giving me a sql error, since the ID column does not exists in the db). Maybe I'm misunderstanding the Id() constructor? constructor comments: Create an Id that doesn't have a corresponding property in the domain object, or a column in the database. This is mainly for use with read-only access and/or views. Defaults to an int identity with an "increment" generator. public class PersonMapping : ClassMap<Person> { public PersonMapping() { Table("person"); ReadOnly(); Id(); Map(f => f.Name,

Entity Framework Fluent Mapping Optional One-To-One

本秂侑毒 提交于 2019-12-04 19:25:56
I need to set up a relationship that is currently a one-to-many: public class Foo { public int FooId { get; set; } public int? BarId { get; set; } ... public virtual Bar Bar { get; set; } } public class Bar { public int BarId { get; set; } ... public virtual ICollection<Foo> Foos { get; set; } } public FooMap() { HasKey(e => e.FooId); Property(e => e.FooId.IsRequired().HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity); Property(e => e.BarId).IsOptional(); ... HasOptional(e => e.Bar).WithMany(Foos).HasForeignKey(e => e.BarId); } public BarMap() { HasKey(e => e.BarId); Property(e => e