Error: 'System.Linq.IQueryable' does not contain a definition for 'Include' and no extension method 'Include' accepting a first argument of type 'System.Linq.IQueryable' could be found
Solution:
Add namespace System.Data.Entity;
Actually Include is not an extension method on Queryable, so it doesn't come with all the usual LINQ methods.
If you are using Entity Framework, you need to import namespace System.Data.Entity:
Wednesday, December 10, 2014
Tuesday, December 9, 2014
the type or namespace name 'expression' could not be found
To remove error "the type or namespace name 'expression' could not be found"
Add namespace System.Linq.Expressions.
as normally System.Linq is there in using part by default and expression class is under system.Linq.Expressions so we have to make it also in using.
Thursday, November 6, 2014
Best Practices for Code Review
Labels:
c#,
Code review,
Peer Code Review,
programming
The cast to value type 'Double' failed because the materialized value is null. Either the result type's generic parameter or the query must use a nullable type
var res =(from profile in dbModel.ProfileMasters select new { ProfileID = profile.ProfileId, Profile = profile.ClientName, Tasks= profile.TaskMasters.Count(), AverageTime = profile.TaskMasters.Select(x => EntityFunctions.DiffMinutes(x.StartTime, x.EndTime)).Average(y => (decimal?)y.Value), LastTime = profile.TaskMasters.Max(x=>x.StartTime) }).ToList();
DbArithmeticExpression arguments must have a numeric common type
dgvProfiles.DataSource = (from profile in dbModel.ProfileMasters select new { ProfileID = profile.ProfileId, Profile = profile.ClientName, Tasks= profile.TaskMasters.Count(), AverageTime = profile.TaskMasters.Select(x => EntityFunctions.DiffMinutes(x.StartTime, x.EndTime)).Average(y => (decimal?)y.Value), LastTime = profile.TaskMasters.Max(x=>x.StartTime) }).ToList();
Labels:
ASP.NET,
ASP.NET MVC,
C#.NET,
Lambda Expression,
LINQ
Thursday, April 3, 2014
The maximum message size quota for incoming messages (65536) has been exceeded
Wednesday, March 26, 2014
Change schema of all tables in database
SELECT 'ALTER SCHEMA NewSchemaName TRANSFER ' + SysSchemas.Name + '.' + DbObjects.Name + ';' FROM sys.Objects DbObjects INNER JOIN sys.Schemas SysSchemas ON DbObjects.schema_id = SysSchemas.schema_id WHERE SysSchemas.Name = 'OldSchemaName' AND (DbObjects.Type IN ('U', 'P', 'V'))now just copy the output of this script and run...
Compiled by: Rajesh Rolen
Saturday, March 22, 2014
Prevent addition of default paragraph tag by ckeditor
by ckeditor we have to add below lines in config.js
CKEDITOR.editorConfig = function (config) { config.enterMode = CKEDITOR.ENTER_BR; config.shiftEnterMode = CKEDITOR.ENTER_BR;
Labels:
ASP.NET,
ASP.NET MVC,
C#.NET,
Ckeditor
Thursday, March 13, 2014
HTTP could not register URL . Your process does not have access rights to this namespace
HTTP could not register URL http://+:8080/FileTranfer/.
Your process does not have access rights to this namespace (see http://go.microsoft.com/fwlink/?LinkId=70353 for details).
The issue is that the URL is being blocked from being created by Windows.
Steps to fix:
Run command prompt as an administrator.
Add the URL to the ACL netsh http add urlacl url=http://+:8080/FileTranfer/ user=mylocaluser
Labels:
ASP.NET,
ASP.NET MVC
Saturday, February 22, 2014
set entity framework connection string programmatically
public static string GetConnectionString(ProfileMaster profile) { //return string.Format("data source={0};initial catalog={1};user id={2};password={3} multipleactiveresultsets=True;App=EntityFramework", profile.DatabaseIP, profile.DatabaseName, profile.UserName, profile.Password); string providerName = "System.Data.SqlClient"; string serverName = profile.DatabaseIP; string databaseName = profile.DatabaseName; // Initialize the connection string builder for the // underlying provider. SqlConnectionStringBuilder sqlBuilder = new SqlConnectionStringBuilder(); // Set the properties for the data source. sqlBuilder.DataSource = serverName; sqlBuilder.InitialCatalog = databaseName; sqlBuilder.IntegratedSecurity = true; // Build the SqlConnection connection string. string providerString = sqlBuilder.ToString(); // Initialize the EntityConnectionStringBuilder. EntityConnectionStringBuilder entityBuilder = new EntityConnectionStringBuilder(); //Set the provider name. entityBuilder.Provider = providerName; // Set the provider-specific connection string. entityBuilder.ProviderConnectionString = providerString; // Set the Metadata location. entityBuilder.Metadata = @"res://*/Models.MoviesDB.csdl| res://*/Models.MoviesDB.ssdl| res://*/Models.MoviesDB.msl"; return entityBuilder.ToString(); }
Compiled By: Rajesh Rolen
Saturday, January 18, 2014
Error for enumerable when using JsonConvert.SerializeObject
[Serializable] public abstract class Entity { public Entity() { } public Entity(int id) { this.Id = id; } public virtual int Id { get; set; } public override bool Equals(object obj) { Entity other = (Entity)obj; return this.Id == other.Id; } public override int GetHashCode() { return this.Id.GetHashCode(); } }
Labels:
ASP.NET,
C#.NET,
Enumerable,
Error,
JsonConvert
Observer Design Pattern in Jquery
Attach a trigger event for publisher $('div').on('click', function(e) { $(this).trigger('MyEvent',e,parameterValue); }); Attach subscriber methods $(document).on('MyEvent', function(e,parameterValue) { //Do your stuffs with parameterValues.. });
Monday, January 13, 2014
Overwrite Appsetting in ASP.NET MVC
var config = WebConfigurationManager.OpenWebConfiguration("~"); config.AppSettings.Settings["appSettingKey"].Value ="Updated value"; config.Save(ConfigurationSaveMode.Minimal, false); ConfigurationManager.RefreshSection("appSettings");
Subscribe to:
Posts (Atom)