我有一个DataGridView,我需要添加自定义对象.请考虑以下代码:
DataGridView grid = new DataGridView();
grid.DataSource = objects;
Run Code Online (Sandbox Code Playgroud)
使用此代码,我得到一个DataGridView对象,其所有属性都是列.就我而言,我不想展示所有这些信息; 我想只展示两三列.我知道我可以设置
AutoGenerateColumns = false.
但我不知道如何继续进行.一种选择是隐藏所有我不感兴趣的列,但我认为最好以相反的方式进行.我怎样才能做到这一点?
我有一个架构public和数据库schema_A.我需要创建一个schema_b结构相同的新模式schema_a.我发现下面的函数,问题是它不复制外键约束.
CREATE OR REPLACE FUNCTION clone_schema(source_schema text, dest_schema text)
RETURNS void AS
$BODY$
DECLARE
object text;
buffer text;
default_ text;
column_ text;
BEGIN
EXECUTE 'CREATE SCHEMA ' || dest_schema ;
-- TODO: Find a way to make this sequence's owner is the correct table.
FOR object IN
SELECT sequence_name::text FROM information_schema.SEQUENCES WHERE sequence_schema = source_schema
LOOP
EXECUTE 'CREATE SEQUENCE ' || dest_schema || '.' || object;
END LOOP;
FOR object IN
SELECT …Run Code Online (Sandbox Code Playgroud) postgresql foreign-key-relationship database-schema postgresql-9.1
我有以下方法在DataGridView上加载产品
private void LoadProducts(List<Product> products)
{
Source.DataSource = products; // Source is BindingSource
ProductsDataGrid.DataSource = Source;
}
Run Code Online (Sandbox Code Playgroud)
现在我试图让我回来保存它们如下图所示.
private void SaveAll()
{
Repository repository = Repository.Instance;
List<object> products = (List<object>)Source.DataSource;
Console.WriteLine("Este es el número {0}", products.Count);
repository.SaveAll<Product>(products);
notificacionLbl.Visible = false;
}
Run Code Online (Sandbox Code Playgroud)
但是我得到了InvalidCastException这条线:
List<object> products = (List<object>)Source.DataSource;
Run Code Online (Sandbox Code Playgroud)
那么如何将DataSource转换为List呢?
我读过collection_check_boxes但我不明白如何设置检查值.我有以下型号:
class Objective < ActiveRecord::Base
has_many :indicators
has_many :objective_children, class_name: "Objective", foreign_key: "parent_id"
def objective_ids
objective_children.collect{|o| o.id}
end
def objective_ids= objectives_ids
objectives_ids.each do |id|
objective_children << Objective.find(id)
end
end
end
Run Code Online (Sandbox Code Playgroud)
编辑视图:
<%= form_for(@objective) do |f| %>
<%= f.collection_check_boxes :objective_ids, Objective.all, :id, :name %>
<%= f.submit %>
<% end %>
Run Code Online (Sandbox Code Playgroud)
html复选框没问题,但我不知道如何设置值objective.我被尝试定义objective_ids= objectives_ids但没有任何反应.
在控制器中:
class ObjectivesController < ApplicationController
def objective_params
params.require(:objective).permit(:name, :code, :description, :objective_ids)
end
end
Run Code Online (Sandbox Code Playgroud)
编辑
日志文件说Unpermitted parameters: perspective_id, objective_ids
checkbox ruby-on-rails view-helpers strong-parameters ruby-on-rails-4
我正在开发一篇关于这篇文章的多租户应用程序.问题是我第一次运行所有迁移.在schema.rb文件中只有公共模式的表,但其他模式发生了什么?如何创建具有不同结构的其他模式,public我不想使用宝石.
请参阅下面的示例
要为公共模式创建的表
class CreatePerspectives < ActiveRecord::Migration
include MultiSchema
def up
with_in_schemas :only => :public do
# Create table perspectives
end
end
def down
with_in_schemas :only => :public do
drop_table :prespectives
end
end
end
Run Code Online (Sandbox Code Playgroud)
要为私有模式创建的表
class CreateObjectives < ActiveRecord::Migration
include MultiSchema
def change
with_in_schemas :except => :public do
# Create objectives table
end
end
end
Run Code Online (Sandbox Code Playgroud)
schema.rb
ActiveRecord::Schema.define(version: 20130810172443) do
create_table "perspectives", force: true do |t|
t.string "name"
t.datetime "created_at"
t.datetime "updated_at"
end
end
Run Code Online (Sandbox Code Playgroud) multi-tenant rails-migrations rails-postgresql ruby-on-rails-4
我正在使用FosRestBundle,我正在使用手动路由声明一个控制器.
namespace Cboujon\PropertyBundle\Controller;
use FOS\RestBundle\Controller\Annotations\QueryParam;
use FOS\RestBundle\Controller\Annotations\RouteResource;
use FOS\RestBundle\View\View;
use FOS\RestBundle\Controller\Annotations\Get;
/**
* Property controller.
* @RouteResource("Property")
*/
class PropertyRESTController extends \FOS\RestBundle\Controller\FOSRestController {
/**
*
* @return type
* @Get("/types")
*
*/
public function getTypesAction() {
...
return $this->get('fos_rest.view_handler')->handle($view);
}
}
Run Code Online (Sandbox Code Playgroud)
使用routing.yml
cboujon_property_property_api:
resource: "@CboujonPropertyBundle/Controller/PropertyRESTController.php"
type: rest
prefix: /api
Run Code Online (Sandbox Code Playgroud)
当我提出要求http://localhost:8000/api/properties/types或者http://localhost:8000/api/property/types我得到了
找不到404 - NotFoundHttpException.
但如果http://localhost:8000/api/types它有效!
我需要配置网址http://localhost:8000/api/properties/types.我究竟做错了什么?
更新1
没有Property实体.PropertyController应该执行自定义操作(无CRUD).
更新2
你可以看到git存储库
我正在使用JHipster,当我运行时,sudo mvn liquibase:diff我得到以下错误
[INFO] Settings
----------------------------
[INFO] driver: org.postgresql.Driver
[INFO] url: jdbc:postgresql://localhost/gastos8
[INFO] username: gastos8
[INFO] password: *****
[INFO] use empty password: false
[INFO] properties file: null
[INFO] properties file will override? false
[INFO] prompt on non-local database? true
[INFO] clear checksums? false
[INFO] changeLogFile: src/main/resources/config/liquibase/master.xml
[INFO] context(s): null
[INFO] label(s): null
[INFO] referenceDriver: null
[INFO] referenceUrl: hibernate:spring:com.cboujon.domain?dialect=org.hibernate.dialect.PostgreSQL82Dialect
[INFO] referenceUsername: null
[INFO] referencePassword: null
[INFO] referenceDefaultSchema: null
[INFO] diffChangeLogFile: src/main/resources/config/liquibase/changelog/20150807132702_changelog.xml
[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] …Run Code Online (Sandbox Code Playgroud) 我是NHibernate的新手.我正在尝试将此ORM与SQLite一起使用.我有以下内容:

Product.cs
namespace Stock.Models.Classes
{
class Product
{
public virtual string Name {get; set;}
public virtual int Id { get; set; }
public virtual decimal Price { get; set; }
public virtual decimal Quantity { get; set; }
}
}
Run Code Online (Sandbox Code Playgroud)
Product.hbm.xml
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
assembly="Stock.Models"
namespace="Stock.Models.Classes">
<class name="Product" table="products">
<id name="Id">
<generator class="int" />
</id>
<property name="Name" />
<property name="Price" />
<property name="Quantity" />
</class>
</hibernate-mapping>
Run Code Online (Sandbox Code Playgroud)
的hibernate.cfg.xml
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
<session-factory>
<property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
<property …Run Code Online (Sandbox Code Playgroud) 我有一个现有的数据库.让我们说我有一个名为的表"transactions",我想创建相应的实体名称"Transaction".我怎样才能做到这一点?
我有一个多类分类器,我需要同时获取概率和标签。
model.predict_proba(X)返回每个数据点的所有训练类的概率。
model.predict(X)返回每个数据点的标签。
我不想对每个数据点预测两次。
c# ×2
datagridview ×2
symfony ×2
.net-4.0 ×1
c#-4.0 ×1
casting ×1
checkbox ×1
datasource ×1
jhipster ×1
liquibase ×1
maven ×1
multi-tenant ×1
nhibernate ×1
php ×1
postgresql ×1
python ×1
scikit-learn ×1
symfony-2.7 ×1
view-helpers ×1
winforms ×1