{System.Data.Entity.DbUpdateException: An error occurred while saving entities that do not expose foreign key properties for their relationships. The EntityEntries property will return null because a single entity cannot be identified as the source of the exception. Handling of exceptions while saving can be made easier by exposing foreign key properties in your entity types. See the InnerException for details. ---> System.Data.UpdateException: An error occurred while updating the entries. See the inner exception for details. ---> System.ArgumentException: Parameter value '12.50000' is out of range.
at System.Data.SqlClient.TdsParser.TdsExecuteRPC(_SqlRPC[] rpcArray, Int32 timeout, Boolean inSchema, SqlNotificationRequest notificationRequest, TdsParserStateObject stateObj, Boolean isCommandProc)
at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result)
at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe)
at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
at System.Data.Mapping.Update.Internal.DynamicUpdateCommand.Execute(UpdateTranslator translator, EntityConnection connection, Dictionary`2 identifierValues, List`1 generatedValues)
at System.Data.Mapping.Update.Internal.UpdateTranslator.Update(IEntityStateManager stateManager, IEntityAdapter adapter)
--- End of inner exception stack trace ---
at System.Data.Mapping.Update.Internal.UpdateTranslator.Update(IEntityStateManager stateManager, IEntityAdapter adapter)
at System.Data.EntityClient.EntityAdapter.Update(IEntityStateManager entityCache)
at System.Data.Objects.ObjectContext.SaveChanges(SaveOptions options)
at System.Data.Entity.Internal.InternalContext.SaveChanges()
--- End of inner exception stack trace ---
Got above error while performing database.save() of Entity Model .
The reason for failure was the decimal field in DB which was set for DECIMAL(6,5) whereas the value trying to be saved was 12.00000 .
This is how it works :
e.g.
decimal of (4,1) can hold upto 999.9
decimal of (3,1) can hold upto 99.9
Friday, September 30, 2011
Tuesday, September 13, 2011
Executing Java .jar within .NET
using System.Diagnostics;
Process process = new Process();
//Path wherein Java is installed in your machine
process.StartInfo.FileName = "java.exe";
//.jar file to be executed
process.StartInfo.Arguments = @"-jar Sample.jar";
process.StartInfo.UseShellExecute = false;
process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.RedirectStandardError = true;
process.Start();
//Get the output from stream
Console.WriteLine(process.StandardOutput.ReadToEnd());
//in case of no error ExitCode will be zero
if(process.ExitCode)
{
//In case of error , get error description
string error = process.StandardError.ReadToEnd();
}
Console.WriteLine(error);
process.WaitForExit();
Process process = new Process();
//Path wherein Java is installed in your machine
process.StartInfo.FileName = "java.exe";
//.jar file to be executed
process.StartInfo.Arguments = @"-jar Sample.jar";
process.StartInfo.UseShellExecute = false;
process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.RedirectStandardError = true;
process.Start();
//Get the output from stream
Console.WriteLine(process.StandardOutput.ReadToEnd());
//in case of no error ExitCode will be zero
if(process.ExitCode)
{
//In case of error , get error description
string error = process.StandardError.ReadToEnd();
}
Console.WriteLine(error);
process.WaitForExit();
Tuesday, August 16, 2011
An entity object cannot be referenced by multiple instances of IEntityChangeTracker.
I got this error due to using separate context object for an entity. I had to use same context object to perform multiple operations in Entity .
Friday, August 12, 2011
Request Error
Specified named connection is either not found in the configuration, not intended to be used with the EntityClient provider
I got this error when i was trying to browse the WCF data Services. The resolution for this issue was to define the connection string for database defined in in app.config file to the web.config file of the web application.
In Nutshell , below is my scnerio :
Project 1 : Contains the .edmx and app.config file
Project 2 : Contains the .SVC referencing entity model defined in project 1 and web.config file
Resolution :
Copy the Db connection defined in app.config to web.config under configuration section .
Thursday, July 21, 2011
Format ComboBox ExtJS
items: [
{
xtype: 'combobox',
fieldLabel: 'State',
store: 'TestStore',
queryMode: 'local',
displayField: 'State',
listConfig: {
getInnerTpl: function () {
return '
{State}:{status}
'; }
}
}
Tab Inside a Tab ExtJS
Ext.create('Ext.TabPanel', {
renderTo: Ext.getBody(),
id: 'main-tabs',
height: 300,
width: 600,
activeTab: 0,
defaults: {
padding: 10
},
items: [{
xtype: 'tabpanel',
title: 'Tab 1',
id: 'tab1',
activeTab: 0,
padding: 5,
border: true,
plain: true,
defaults: {
padding: 10
},
items: [{
title: 'Sub-tab 1',
id: 'subtab1',
html: 'Sub-tab 1 content'
},{
title: 'Sub-tab 2',
id: 'subtab2',
html: 'Sub-tab 2 content'
},{
title: 'Sub-tab 3',
id: 'subtab3',
html: 'Sub-tab 3 content'
}]
},{
title: 'Tab 2',
id: 'tab2',
html: 'Tab 2 content'
},{
title: 'Tab 3',
id: 'tab3',
html: 'Tab 3 content'
},{
title: 'Tab 4',
id: 'tab4',
html: 'Tab 4 content'
},{
title: 'Tab 5',
id: 'tab5',
html: 'Tab 5 content'
}]
});
});
Adding panel to ViewPort (ExtJS)
Add Panels to ViewPort on the fly
1) Define ViewPort
viewport = Ext.create('Ext.container.Viewport', {
layout: {
type: 'border'
},
defaults: {
split: false
},
items: [{
region: 'center',
layout: 'border',
frame: false,
padding: '0 5 0 0',
border: false,
items: [{
region: 'center',
items: [
{
xtype: 'grid1'
}
]
}]
},
{
region: 'south',
frame: false,
padding: '0 5 0 0',
border: false
}
]
});
2) Add panel on the fly to defined region. In our example we are adding panel to "South" region
southRegion = viewport.getComponent(1);
southRegion .add(myPanel);
southRegion .setWidth(200);
southRegion .doLayout();
Tuesday, July 19, 2011
Regular Expression for YYYYMM
Well i managed to make this one for now. If you have better one please share .
YYYYMM
(^(19|20)\d{2})((0[1-9])|(1[0-2])$)
e.g.
PASS : 200901 , 201012 ...
FAILS :211001 , 200913 ...
YYYYMM
(^(19|20)\d{2})((0[1-9])|(1[0-2])$)
e.g.
PASS : 200901 , 201012 ...
FAILS :211001 , 200913 ...
Sunday, July 17, 2011
Friday, July 08, 2011
Get Security Information from Client
In order to get the security information from client in a Service , use the following Class :
ServiceSecurityContext Class
ServiceSecurityContext.Current.WindowsIdentity.Name
ServiceSecurityContext.Current.PrimaryIdentity.Name
More Information:
http://msdn.microsoft.com/en-us/library/system.servicemodel.servicesecuritycontext.aspx
ServiceSecurityContext Class
ServiceSecurityContext.Current.WindowsIdentity.Name
ServiceSecurityContext.Current.PrimaryIdentity.Name
More Information:
http://msdn.microsoft.com/en-us/library/system.servicemodel.servicesecuritycontext.aspx
Wednesday, June 22, 2011
Message: Expected identifier, string or number
If you get this error in your Ext JS page , then there is big possibility that you have added a extra comma which is not required .
E.g.
Incorrect entry
{
title: 'Main Content',
collapsible: false,
region: 'center',
layout: 'fit',
margins: '5 0 0 0',
xtype: 'panelbais' , }
Correct entry
{
title: 'Main Content',
collapsible: false,
region: 'center',
layout: 'fit',
margins: '5 0 0 0',
xtype: 'panelbais' }
Check out the last comma before the closing curly braces .
Monday, June 20, 2011
'undefined' is null or not an object in ext-all.js
One more ext-all.js error . This time it was due to extra comma in object literal definition.
Resolution :
Find and remove extra comma.
'flex' is null or not an object in ext-all.js
I got this error for quite some time and i had no clue what was wrong in my page . Page consisted of only 2 panel controls . That's all
After playing around with some of properties of panel , the issue was resolved.
Issue in my case :
First panel had property layout: 'anchor'
Second Panel had property layout: 'border '
Resolution :
Changed the second panel property layout: 'anchor'
This might not be your case . This error is very generic and can pop up due to multiple reasons .
Ext JS : Data Model proxy for Json and XML return type
JSON RETURN DATA
If you data is returned in JSON format then your proxy for Data Model will look like :
Ext.define("Post", {
extend: 'Ext.data.Model',
proxy:
{
type: 'rest',
url : 'http://xyz.com/ID/18/',
reader: {
type: 'json',
root: 'CUSTOMER'
}
}
XML Return Data
Ext.define("Post", {
extend: 'Ext.data.Model',
proxy: {
type: 'ajax',
url : 'http://xyz.com/ID/18',
reader: {
type: 'xml',
record: 'CUSTOMER'
}
},
Ext JS Programming Basic Requirement
So , if you have started working with Ext JS make sure you are using the following tools . Believe me they are quite handy and saves you from head banging ;-)
1) Fiddler
2) Scripting client
3) REST Service Tested ( Firefox)
4) Firebug
Thursday, June 16, 2011
Could not find default endpoint element that references contract 'x' in the ServiceModel client
Scenario :
I was creating a WCf client to test the services . After creating client proxy and testing the services i bumped into below error. It seems the configuration in my app.config was not correct.
{System.InvalidOperationException: Could not find default endpoint element that references contract 'x' in the ServiceModel client configuration section. This might be because no configuration file was found for your application, or because no endpoint element matching this contract could be found in the client element.
Resolution :
When you generate client using the svcutil.exe , an output.xml is generated. This file contains the end point configuration information . Take the configuration from this file and add it to app.config. Service should work without configuration issue assuming your code is not erroneous ;-)
Wednesday, June 15, 2011
Visual Studio IntelliSense to show comments for the Custom Function
If you added Summary to your custom defined function and it's still now showing description as part of Visual Studio IntelliSense then for sure you are missing a setting .
e.g.
///<summary>
This is test function
///</summary>
public void TestFunction()
{
//Do something...
}
when you access this function , you expect the description to show up but in case its shows nothing . Then do this :
1) Open Projects property page
2) Click the Build Tab
30 Check the "Xml documentation file " checkbox
Compile project and try once more ...
Wednesday, June 08, 2011
Accessing Enterprise Application Blocks
There are mutiple ways to access application blocks :
Using the Enterprise Library Service Locator
var writer = EnterpriseLibraryContainer.Current.GetInstance();
writer.Write("I'm a log entry created by the Logging block!");
var customerDb
= EnterpriseLibraryContainer.Current.GetInstance("Customers");
The Sophisticated Approach — Accessing the Container Directly
var theContainer = new
UnityContainer().AddNewExtension();
var writer = theContainer.Resolve();
writer.Write("I'm a log entry created by the Logging block!");
var customerDb = theContainer.Resolve("Customers");
Check out this diagram :
http://msdn.microsoft.com/en-us/library/Ff953191.441da4ba-fa2e-4da3-bac1-89897580d80b(l=en-us,v=PandP.50).png
Subscribe to:
Posts (Atom)
Reference Architecture: Building a Cost Optimized, High-Throughput HL7, EDI, and FHIR Processing Pipeline on OCI ( Published in Oracle Blog)
OCI (Oracle Cloud Infrastructure) provides more than 200 services to build your next enterprise application. Explore the blog to learn how ...
-
Ever wanted to have a people picker kind of control in Infopath form and that too in browser mode. Did i heard yes :) , well there is a Acti...
-
Am sure lot's of people would be wondering how to hide menu items of a list eg document libraries "Send to " menu item . In o...
-
I got this error for quite some time and i had no clue what was wrong in my page . Page consisted of only 2 panel controls . That's all ...