Search This Blog

Monday, March 11, 2019

Encrypt and Decrypt Connection String using CMD


Encrypt:


cd C:\Windows\Microsoft.Net\Framework\v4.0.30319
ASPNET_REGIIS -pef "appSettings" "folder path where web.config"


DeCrypt:

cd C:\Windows\Microsoft.Net\Framework\v4.0.30319
ASPNET_REGIIS -pdf "appSettings" "folder path where web.config"





Wednesday, March 6, 2019

SQL Query to Get size of Table

EXEC sp_spaceused N'User.ContactInfo';

SQL Query to Get Table Index fragmentation

Query:

SELECT * FROM sys.dm_db_index_physical_stats(dbid, table_objectid, NULL, NULL , 'LIMITED')
ORDER BY avg_fragmentation_in_percent DESC

SQL Query to Get Database ID and Table Object ID in Dynamics CRM

Get DB Id:

SELECT DB_ID(N'dbname') AS [Database ID];


Get Table Object ID:

Use dbname
SELECT name, object_id 
FROM sys.tables 
WHERE name = 'IncidentBase'; 
GO

Friday, March 1, 2019

Get and Set Dynamics CRM Attribute Values in c#

Set OptionsetValue:

entity.Attributes.Add("attributename", new OptionSetValue(1));

Set Money Attribute:

Decimal  creditlimit=0;

entity.Attributes.Add("attributename", new Money(creditlimit));

Set Lookup:

EntityReference _event = new EntityReference();
                        _event.Id = guid;
                        _event.LogicalName = "entityname";
                        _event.Name = name;
                        entity.Attributes["attributename"] = _event;

DateTime:

entity.Attributes.Add("attributename", Start_date);

Get Alias Attribute Values in Dynamics CRM using c#

Single Line of Text:

String name = ((AliasedValue)entity.Attributes["name"]).Value.ToString();


OptionsetValue:

String optionsetvalue = ((AliasedValue)entity.Attributes["attributename"]).Value.ToString();


OptionsetText:

String optionsettext = entity.FormattedValues["attributename"].ToString();


Lookup:

String name = ((EntityReference)((AliasedValue)entity.Attributes["attributename"]).Value).Name;
String id= ((EntityReference)((AliasedValue)entity.Attributes["attributename"]).Value).Id.ToString();


Currency:
 Fetchxml Query:

<entity name='account'>
                <attribute name='name' />
                <attribute name='accountid' />
                <order attribute='name' descending='false' />
                <filter type='and'>
                  <condition attribute='statecode' operator='eq' value='0' />
                </filter>
                <link-entity name='amountentity' from='amountentityid' to='amountentity' visible='false' link-type='outer' alias='amount_entity'>
                  <attribute name='totalamount' />
                </link-entity>
              </entity>

Decimal amount = ((Money)(((AliasedValue)student.Attributes["amount_entity.totalamount"])).Value).Value;


Whole Number:

int Totalnumber = Convert.ToInt16(((AliasedValue)entity.Attributes["totalcredithours"]).Value);