autogeneratecolumn

EF6: How to generate a unique number automatically based on entity Id

╄→гoц情女王★ 提交于 2020-01-03 05:25:08
问题 Consider an entity like this: public class Document { public int Id { get; set; } public long code { get; set; } // Rest of Props } What I need is to generate a unique long code, and I prefer to generate it based on Id. One simple classic but unsafe solution is to get the last Id and increase it by one and use, but I'm looking for a better solution, such as computed column, or any other way to assign code generation to database. I cannot access to Id if I try define it as a compute column.

How to set background of a datagrid cell during AutoGeneratingColumn event depending on its value?

不羁岁月 提交于 2019-12-29 06:10:34
问题 I'm still fighting with manipulation of cell backgrounds so I'm asking a new question. A user "H.B." wrote that I can actually set the cell style during the AutoGeneratingColumn event - Change DataGrid cell colour based on values. The problem is that I'm not sure how to do it. What I want: Set different background colours for each cell depending on its value. If the value is null I also want it not to be clickable (focusable I guess). What I have / I'm trying to do: private void mydatagrid

How to update programmatically the items source in an autogenerated datagrid combobox cell

非 Y 不嫁゛ 提交于 2019-12-25 08:06:18
问题 I can't find a working solution to my issue I have a datagrid binded to an object collection. one of my object property is used as an index in a collection. The autogenerated combobox column "Type" displays the "label" associated to this index. I need to update another property which is an index too in that same object. I use this code to add the combobox in the AutogeneratingColumn event : public partial class LedTableEditor : MetroWindow, INotifyPropertyChanged { private object _sender;

DB2: How to get generated always as statement to work with session user

好久不见. 提交于 2019-12-25 04:20:52
问题 I need to get a userstamp into a table and have not managed to figure out how the GENERATED FOR EACH ROW ON UPDATE AS statement works with the SESSION_USER variable in DB2 10.5 (LUW). Managed to get an implementation working using a function which has a fake variable for forcing the evaluation in update statements: CREATE OR REPLACE FUNCTION XXX.CURRENT_USER( tmp varchar(128)) SPECIFIC xxx.XXX_CURRENT_USER RETURNS VARCHAR(128) CONTAINS SQL DETERMINISTIC NO EXTERNAL ACTION BEGIN RETURN session

DB2: How to get generated always as statement to work with session user

天涯浪子 提交于 2019-12-25 04:20:06
问题 I need to get a userstamp into a table and have not managed to figure out how the GENERATED FOR EACH ROW ON UPDATE AS statement works with the SESSION_USER variable in DB2 10.5 (LUW). Managed to get an implementation working using a function which has a fake variable for forcing the evaluation in update statements: CREATE OR REPLACE FUNCTION XXX.CURRENT_USER( tmp varchar(128)) SPECIFIC xxx.XXX_CURRENT_USER RETURNS VARCHAR(128) CONTAINS SQL DETERMINISTIC NO EXTERNAL ACTION BEGIN RETURN session

how do i escape a slash character in a WPF binding path, or how to work around?

末鹿安然 提交于 2019-12-19 15:44:29
问题 I'm just learning WPF, and I gragged a table from a datasource onto a window which generated XAML for each column. Some of those columns had names that caused the following: <DataGridTextColumn x:Name="_Rev_UnitColumn" Binding="{Binding Path=Rev/Unit}" Header="Rev/Unit" Width="SizeToHeader" /> This causes the column to come up blank (like me). 回答1: I (kind of randomly) tried: <DataGridTextColumn x:Name="_Rev_UnitColumn" Binding="{Binding Path=[Rev/Unit]}" Header="Rev/Unit" Width="SizeToHeader

Auto-generate field value on sfGuardUser when registering

大憨熊 提交于 2019-12-14 02:26:39
问题 I'm building a Symfony 1.4 project that is using sfDoctrineGuardPlugin for users/authentication. I have a field on my user table named "access_token" that I would like to populate with an auto-generated value upon user registration. I see that for registration, the sfGuardRegisterForm is used for validation. Unfortunately, when I run ./symfony doctrine:build-forms from the command line, this form doesn't appear to be extended, meaning that I can't generate an access token there without

Get SQL Computed Column Inserted Value

夙愿已清 提交于 2019-12-10 10:44:57
问题 My Table Structure as follow, CREATE TABLE tbl_Info ( [SSEID] BIGINT NOT NULL IDENTITY(1,1), [ShortenKey] AS ConvertToBase([SSEID]), [Title] VARCHAR(500) NULL, ) ConvertToBase Function as Follow, CREATE FUNCTION ConvertToBase(@Number BIGINT) RETURNS VARCHAR(15) AS BEGIN // implementation END I need to get the generated [ShortenKey] value after INSERT query in sp. how to do this ? 回答1: Use the OUTPUT clause? INSERT tbl_Info (Title) OUTPUT INSERTED.ShortenKey VALUES ('new title') Note: may not

How do you rename DataGrid columns when AutoGenerateColumns = True?

与世无争的帅哥 提交于 2019-12-04 09:13:42
问题 I have a simple data structure class: public class Client { public String name {set; get;} public String claim_number {set; get;} } Which I am feeding into a DataGrid : this.data_grid_clients.ItemSource = this.clients; I would like to change the column headings. Ie: claim_number to "Claim Number". I know this can be done when you manually create the columns by doing something like: this.data_grid_clients.Columns[0].Header = "Claim Number" However, the Columns property is empty when auto

How do you rename DataGrid columns when AutoGenerateColumns = True?

你离开我真会死。 提交于 2019-12-03 02:20:57
I have a simple data structure class: public class Client { public String name {set; get;} public String claim_number {set; get;} } Which I am feeding into a DataGrid : this.data_grid_clients.ItemSource = this.clients; I would like to change the column headings. Ie: claim_number to "Claim Number". I know this can be done when you manually create the columns by doing something like: this.data_grid_clients.Columns[0].Header = "Claim Number" However, the Columns property is empty when auto-generating the columns. Is there a way to rename the columns, or do I have to manually generate the columns?