i have a column in database that takes a bit value(1,0). the default is set to 1. I am using Linq. when I try to change the value it gives me this exception.
A member that is computed or generated cannot be changed.
in Linq
[global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_IsDefault", DbType="Bit NOT NULL",IsDbGenerated="true" )]
if I remove the IsDbGenerated Attribute. I am able to change the values but when I import some data directly using a CSV file then the default value is always coming 0 but it was set to 1 in the DB.
Can't you set the default value of the field or property in code to 1 (or true) as well? You could also set the default in the constructor of the object that the field belongs to.
Related
I have problem how to get value of column inside contentype of this via keyword Query in this link
https://learn.microsoft.com/en-us/microsoft-365/compliance/keyword-queries-and-search-conditions?view=o365-worldwide
i want to get value of any containt SRSItemType = record
First check if SRSItemType column is mapped in Managed Property. If it isn't mapped in Managed Property you can't use it in KQL.
Look at this video https://www.youtube.com/watch?v=xzyLCZPd3d8
Is there a built-in command which sets a value of a stored key, only if that value is smaller/bigger then some parameter?
Or my only solution here is to make two calls to the cache - one for checking the value, the other one (possible one) for storing a new value?
Thanks
Hi my problem is that my EF 4.0 mapping does not replicate the Default value of some columns.
For example
in my Question object i have an int type field Status for which i have set Allow null = false (un-check the allow null checkbox) and set its default value to be 1.
Now the strange behavior is when i insert the record in sql server and doesn't set the status field, it works fine and set the value 1 in record after commit.
But my entity framework mapping (.edmx file) doesn't set the default value and it says "Default value = (None)" in property window.
Is that a known issue or i am missing something?
I had this exact same issue a few months back and I did not find any easy resolution to the problem.
I can only suggest that you manually decorate your entities from within your edmx or if possible upgrade to EF 6 and use the Code-First from database option which from my experience works much better.
I am attempting to create a plug-in that will populate a option set field with a value that is in a string field on an entity.
Here's how I think it would happen, just don't know how to approach it:
-Plug-in is fired, via create message;
-Plug-in gets the 'Target' entity, and checks if the string field is populated;
-If the string value is the same as an Option Set value's label, set the option set field value on the target entity;
-Update the target entity with the option set field populated.
I can accomplish all the steps, minus the comparing the string value to existing option set values. I'm not sure how to retrieve all the Option Set data to search through it.
I have this enum:
public enum SupportedISOCurrencySymbol { DKK = 208, EUR = 978, NOK = 578, SEK = 752 }
I save the value for an order in the approved_orders table, Currency field.
I populate the sql insert query with a parameter like:
cmd.Parameters.AddWithValue("?Currency", this.Currency);
Well, If i do debug on the above line I clearly see that this.Currency has value DKK.
Why then it inserts in the DB: 208?
Do you have any ideea?
Thanks.
SupportedISOCurrencySymbol is an enum, which has integer as base. "DKK" represents the number 208.
What you are seeing in the debug window, is the value of .ToString() on your enum, which is defined to return the name of the enum, not the value. If you want to send the string "DKK" to your database, you could simply state it explicitly:
cmd.Parameters.AddWithValue("?Currency", this.Currency.ToString());
Of course, the columns involved in the database would then need to be of a compatible text type.
"DKK" is a friendly name for the value "208" for you (as programmer) to use in your code.
When the code is compiled all occurrences of "DKK" are replaced by "208" which will include the code that inserts the value into the database.
You could change your database schema to hold a string rather than an integer and store the name of the enum rather than it's value - but you would need to parse the string into an enum when reading it back out of the database into your code.
do you need to add a this.Currency.ToString()? so as to get the text not the numeric value of the enum?