Friday, April 29, 2016

Entity framework Generic Repository

public class GenericRepository<TEntity> where TEntity : class
    {
        internal DbContext context;
        internal DbSet<TEntity> dbSet;

        public GenericRepository()
        {
            this.context = new EWEFDTO();
            this.dbSet = context.Set<TEntity>();
        }

        public virtual IEnumerable<TEntity> Get(
            Expression<Func<TEntity, bool>> filter = null,
            // Expression<Func<TEntity, bool>> orderBy = null,
            Func<IQueryable<TEntity>, IOrderedQueryable<TEntity>> orderBy = null,
            string includeProperties = "", int iOffset=0,int iMax=10)
        {
            IQueryable<TEntity> query = dbSet;

            if (filter != null)
            {
               query = query.Where(filter);
                //return query.OrderBy(filter).ToList();
            //    return query.ToList();
            }

            foreach (var includeProperty in includeProperties.Split
                (new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries))
            {
                query = query.Include(includeProperty);
            }

            if (orderBy != null)
            {
                query= orderBy(query);
            }
            if (iOffset > 0)
                iOffset = iOffset * iMax;
            if (iMax == 0)
                iMax = 10;
            if (orderBy != null)
                return query.Skip(iOffset).Take(iMax).ToList();
            else
                return query.ToList();
           // }
        }

        public virtual TEntity GetByID(object id)
        {
            return dbSet.Find(id);
        }

        public virtual TEntity Insert(TEntity entity)
        {
           return dbSet.Add(entity);
        }

        public virtual void Delete(object id)
        {
            TEntity entityToDelete = dbSet.Find(id);
            DeleteEntity(entityToDelete);
        }

        public virtual void DeleteEntity(TEntity entityToDelete)
        {
            if (context.Entry(entityToDelete).State == EntityState.Detached)
            {
                dbSet.Attach(entityToDelete);
            }
            dbSet.Remove(entityToDelete);
        }

        public virtual void Update(TEntity entityToUpdate)
        {
            //TEntity objTEntity = dbSet.Find(3);

            //TEntity objNewEntity = (TEntity)ReflectionHelper.SetDTOValueFromEntity(objTEntity, entityToUpdate);
            //context.Entry(objNewEntity);
            dbSet.Attach(entityToUpdate);
            context.Entry(entityToUpdate).State = EntityState.Modified;
        }

        public virtual int SaveChanges()
        {
            return context.SaveChanges();
        }
    }

Thursday, April 28, 2016

MS CRM version explanation

The first digit indicates the application version(CRM 5 - 2011, 6 - 2013, 7 - 2015)
The second digit indicates the service pack level.
The third digit indicates the update rollup.

From CRM 2015 New Name conversion for Version

The first three numbers of the 7-digit version number tell you most everything you need to know about which version you’re working with, whether you’re using CRM Online or CRM (on-premises):

Three things have changed in regard to naming conventions:
  • CRM Online. Product names for minor releases of CRM Online will now include the year as part of the name. For example, the spring release of CRM Online for 2015 is CRM Online 2015 Update 1. If there’s an incremental update that applies to the minor release, it will be appended to the name. For example, the first incremental update to the spring 2015 release would be called CRM Online 2015 Update 1.1.
  • CRM (on-premises). In the past, incremental updates for the on-premises version of Microsoft Dynamics CRM were called “Update Rollups”. In the future, Update Rollups will just be called “Updates” and will be associated with the third digit of the version number. For example, the first incremental update for version 7.0 is CRM 2015 Update 0.1. The complete version number in this case is 7.0.1.xxxx, which indicates that the update applies to the major 7.0 release, not a spring release. There will not be a spring 2015 release for the on-premises version, but if there’s a minor fall release, it would be called CRM 2015 Update 2, and any subsequent incremental updates would be appended to that number.
  • CRM for phones. The new phone app introduced with CRM Online 2015 Update 1 will be called CRM for phones. The CRM phone app for CRM 2013 and CRM 2015 will now be called CRM for phones express.

Disabled "Send Error Report" in microsoft dynamics CRM has an encourtered problem

Disabled "Send Error Report" in microsoft dynamics CRM has an encourtered problem

In CRM Settings -> Administrator->Privacy Preferences




Friday, April 22, 2016

How to re-assign records for disabled users?

Go to users-> open disabled users and click re-assign records button in the ribbon and assign to any one


Friday, April 15, 2016

Pre Image and Post Image in CRM


POST Image
It would not have any data in the "PRE operation". Only data access in the "POST operation".
 you get the image of the record as is stored in the SQL database before the CRM Platform action has been performed.


PRE Image
It would have data on both "PRE and POST operation".
It  returns the image of the record after the CRM Platform action has been performed.


POSTOperation                       



Create Update Delete
PRE Image Y Y Y
POST Image Y Y N








PRE Operation



Create Update Delete
PRE Image N Y Y
POST Image N N N

OR
 The following table explains the Pre-Image Availability


The following table explains the Post-Image Availability






Wednesday, April 13, 2016

ASP.NET Web API application gives 404 when deployed at IIS 7

This issue can also happen due to the following
1.In the Web.Config
<system.webServer>
     <modules runAllManagedModulesForAllRequests="true" /> 
</system.webServer>
2.Make sure the following are available in the bin folder on the server where the Web API is deployed
•System.Net.Http
•System.Net.Http.Formatting
•System.Web.Http.WebHost
•System.Web.Http
These assemblies won't be copied in the bin folder by default if the publish is through Visual Studio because the Web API packages are installed through Nuget in the development machine. Still if you want to achieve these files to be available as part of Visual Studio publish then you need to set CopyLocal to True for these Assemblies

Monday, April 11, 2016

Line break or Add new line in SSRS text box

Add " System.Environment.NewLine " in the SSRS text box

Friday, April 8, 2016

How to get remove Blank or white page in PDF exported in SSRS


  • Click on Report > Report Properties > Layout tab (Page Setup tab in SSDT-BI)
  • Make a note of the values for Page width, Left margin, Right margin
  • Close and go back to the design surface
  • In the Properties window, select Body
  • Click the + symbol to expand the Size node
  • Make a note of the value for Width


To render in PDF correctly Body Width + Left margin + Right margin must be less than or equal to Page width. When you see blank pages being rendered it is almost always because the body width plus margins is greater than the page width.

Remember: (Body Width + Left margin + Right margin) <= (Page width)