By the way, this is how we implemented this in our little hack:
Code: Select all
if (WcfDataContractAttributes)
if (relationProperty.Multiplicity != Multiplicity.Many)
GenerateRelationWcfDataContractAttributes(relationProperty);
Code: Select all
if (WcfDataContractAttributes)
if (relationProperty.Multiplicity != Multiplicity.Many)
GenerateRelationWcfDataContractAttributes(relationProperty);
Code: Select all
from r in RetailerDeliveries
group r by r.RetailerNumber into grouped
select new
{
DistinctCount = grouped.Select(d => d.Date).Distinct().Count()
}
Code: Select all
SELECT
[Distinct1].[LVKNR] AS [LVKNR],
(SELECT
COUNT(1) AS [A1]
FROM ( SELECT DISTINCT
[Extent2].[LVDAT] AS [LVDAT]
FROM [INFOSOFT].[LVLEVERANSER] AS [Extent2]
WHERE [Distinct1].[LVKNR] = [Extent2].[LVKNR]
) AS [Distinct2]) AS [C1]
FROM ( SELECT DISTINCT
[Extent1].[LVKNR] AS [LVKNR]
FROM [INFOSOFT].[LVLEVERANSER] AS [Extent1]
) AS [Distinct1]
Code: Select all
select
(select Col from (select '1' as Col where Col = Bar.Col) Foo)
from (select '1' as Col) Bar;
Code: Select all
select
(select Col from (select '1' as Col from dual where Col = Bar.Col) Foo)
from (select '1' as Col from dual) Bar;
Code: Select all
create table TypeColumnTestTable
(
pk int primary key,
type varchar(10) not null
);
Code: Select all
SELECT type FROM TypeColumnTestTable;
SELECT TYPE FROM TypeColumnTestTable;
SELECT TyPe FROM TypeColumnTestTable;
SELECT "TYPE" FROM TypeColumnTestTable;
Code: Select all
SELECT "type" FROM TypeColumnTestTable;
Code: Select all
// Create an adapter and a command builder.
OracleDataAdapter adapter = new OracleDataAdapter();
OracleCommandBuilder commandBuilder = new OracleCommandBuilder(adapter);
// Create a connection, and a command to be used as a SelectCommand.
OracleConnection connection = new OracleConnection(*some connection string*);
OracleCommand command = connection.CreateCommand();
command.CommandText = *insert select statement here*
adapter.SelectCommand = command;
// Imagine some code that creates a data set and adds a new row to it here.
// Call Update on the adapter, passing it the data set.
adapter.Update(*the dataset*);
Code: Select all
command.CommandText = "SELECT pk, TYPE FROM TypeColumnTestTable";
command.CommandText = "SELECT pk, \"TYPE\" FROM TypeColumnTestTable";
command.CommandText = "SELECT * FROM TypeColumnTestTable";
Code: Select all
command.CommandText = "SELECT \"pk\", \"TYPE\" FROM TypeColumnTestTable";
command.CommandText = "SELECT pk, \"type\" FROM TypeColumnTestTable";
Code: Select all
command.CommandText = "SELECT pk, type FROM TypeColumnTestTable";
Code: Select all
Devart.Data.Oracle.OracleException was unhandled
Message=ORA-01400: cannot insert NULL into ("INFOSOFT"."TYPECOLUMNTESTTABLE"."TYPE")
Source=System.Data
ErrorCode=-2147467259
Code=1400
Offset=0
StackTrace:
at System.Data.Common.DbDataAdapter.UpdatedRowStatusErrors(RowUpdatedEventArgs rowUpdatedEvent, BatchCommandInfo[] batchCommands, Int32 commandCount)
at System.Data.Common.DbDataAdapter.UpdatedRowStatus(RowUpdatedEventArgs rowUpdatedEvent, BatchCommandInfo[] batchCommands, Int32 commandCount)
at System.Data.Common.DbDataAdapter.Update(DataRow[] dataRows, DataTableMapping tableMapping)
at System.Data.Common.DbDataAdapter.UpdateFromDataTable(DataTable dataTable, DataTableMapping tableMapping)
at System.Data.Common.DbDataAdapter.Update(DataSet dataSet, String srcTable)
at System.Data.Common.DbDataAdapter.Update(DataSet dataSet)
at ColumnNamedTYPEProject.Program.Main(String[] args) in c:\Users\magbakke\Documents\Visual Studio 2010\Projects\ColumnNamedTYPEProject\Program.cs:line 93
InnerException:
Code: Select all
INSERT INTO TYPECOLUMNTESTTABLE (PK) VALUES (:p1)
Code: Select all
DECLARE
updatedRowid ROWID;
BEGIN
INSERT INTO INFO.PRODUCTS("Id", "FunctionGeneratedValue", "ProductName", "Price", "ModifiedBy", "LastModified")
VALUES (MY_SEQUENCE.NEXTVAL, MY_FUNCTION(), :p0, :p1, USER, current_timestamp)
RETURNING ROWID INTO updatedRowid;
OPEN :outParameter FOR SELECT "Id", "FunctionGeneratedValue" FROM INFO.PRODUCTS WHERE ROWID = updatedRowid;
END;
Code: Select all
DECLARE
updatedRowid ROWID;
BEGIN
INSERT INTO INFO.PRODUCTS("ProductName", "Price")
VALUES (:p0, :p1)
RETURNING ROWID INTO updatedRowid;
OPEN :outParameter FOR SELECT "Id", "FunctionGeneratedValue", "ModifiedBy", "LastModified" FROM INFO.PRODUCTS WHERE ROWID = updatedRowid;
END;
Code: Select all
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
#region Products
modelBuilder.Entity()
.HasKey(p => new { p.Id })
.ToTable("PRODUCTS", "INFO");
// Properties:
modelBuilder.Entity()
.Property(p => p.Id)
.IsRequired()
.HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity);
modelBuilder.Entity()
.Property(p => p.ProductName)
.IsRequired()
.HasMaxLength(160)
.IsUnicode(false);
modelBuilder.Entity()
.Property(p => p.Price);
modelBuilder.Entity()
.Property(p => p.FunctionGeneratedValue)
.IsRequired()
.HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity);
modelBuilder.Entity()
.Property(p => p.ModifiedBy)
.IsRequired()
.HasMaxLength(30)
.HasDatabaseGeneratedOption(DatabaseGeneratedOption.Computed)
.IsUnicode(false);
modelBuilder.Entity()
.Property(p => p.LastModified)
.IsRequired()
.HasDatabaseGeneratedOption(DatabaseGeneratedOption.Computed);
#endregion
#region Disabled conventions
modelBuilder.Conventions.Remove();
modelBuilder.Conventions.Remove();
#endregion
}
Code: Select all
modelBuilder.Entity()
.HasOptional(p => p.Foo1)
.WithMany(c => c.Foos)
.HasForeignKey(p => new { p.FooId })
.WillCascadeOnDelete(false);
I think the generated code is wrong. As far as I can tell the HasForeignKey line should say:One or more validation errors were detected during model generation:
System.Data.Edm.EdmAssociationType: : Multiplicity conflicts with the referential constraint in Role 'Foo_Foo1_Target' in relationship 'Foo_Foo1'. Because all of the properties in the Dependent Role are non-nullable, multiplicity of the Principal Role must be '1'.
System.Data.Edm.EdmAssociationEnd: : Multiplicity is not valid in Role 'Foo_Foo1_Source' in relationship 'Foo_Foo1'. Because the Dependent Role refers to the key properties, the upper bound of the multiplicity of the Dependent Role must be �1�.
Code: Select all
.HasForeignKey(p => new { p.FooReferenceId })