Advertisements

Archive

Author Archive

MySQL : The host localhost does not support SSL connections


When I moved database MySql.Data 7.0.7 to 8.0.8. I got following error

The host localhost does not support SSL connections.

So, here is the solution for this error ,Just add SslMode=none in connection string

server=localhost;user id=roor;password=xyz;persistsecurityinfo=True;port=123;database=TestDB; SslMode=none

Hope it helps !

Advertisements
Categories: ASP.NET, Sql Server

How to Add space and increase width of Morris.Js Bar?


There are two properties of Morris.Js bar we can use to achieve this
1) barGap
2) barSizeRatio

barGap is an integer that sets the space between bars in a single bar group.
Default is 3.
Increase this value to space them further, decrease it to bring them closer.

barSizeRatio is the proportion of the width of the entire graph given to bars. Defaults to 0.75.
Increase the number closer to 1 to make the bars wider, if its =1 the bars will take up the entire graph, if its > 1 bars will overlap.

Here is an example of code

Morris.Bar({
barGap:4,
barSizeRatio:0.55,
element: ‘bar-chart’,
data: [
{ y: ‘Apr’, a: 75, b: 60, c: 5, d: 50 },
{ y: ‘May’, a: 180, b: 220, c: 140, d: 160 },
{ y: ‘June’, a: 420, b: 340, c: 350, d: 270 }
],
xkey: ‘y’,
ykeys: [‘a’, ‘b’, ‘c’, ‘d’],
labels: [‘A’, ‘B’, ‘C’, ‘D’],
barColors: [‘#0B62A4′,’#f75b68′,’#4DA74D’,’#646464′],
hideHover: ‘auto’
});

Hope it helps!

Categories: ASP.NET Tags: , , ,

How to fix function is ambiguous in the namespace ‘system’ compiler error


When you are upgrading your project framework its possible that old version of DLL reference still exists , to remove that follow the below steps

-Open Object Explorer in Visual Studio
-Find that function
-Find the function/dll which has old reference and delete it

Hope it helps!

Categories: ASP.NET

Call Repeater ItemCommand event manually from outside the repeater

February 6, 2018 Leave a comment

Following is the code to call repeater item command event manually

Private Sub btnTest_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnTest.Click

For i = 0 To rptPlayers.Items.Count – 1

Dim tItem As RepeaterItem = rptPlayers.Items(i)

Dim tButton As ImageButton = ptPlayers.Items(i).FindControl(“imgAdd”)

Dim tEvents As New System.Web.UI.WebControls.CommandEventArgs(tButton.CommandName, tButton.CommandArgument)

Dim rpt As New RepeaterCommandEventArgs(tItem, tButton, tEvents)

rptPlayers_ItemCommand(tButton, rpt)

Next

End Sub

Categories: ASP.NET

Telerik ORM : Row not found: GenericOID@ OptimisticVerificationException

January 12, 2018 Leave a comment

This kind of error occurred When DataAccess tries to update the row in the database which has the original values for the fields that have changed.

The reason the update fails is that the artificial columns added at runtime are nullable but the CLR property which these columns are mapped to are all non-nullable. Ex – bit column is mapped to Boolean CLR property.

The generated UPDATE statement tries to find a row with the CLR default value i.e 0 but the value in the column is NULL.

I have updated the method that maps the artificial properties as follows –

var propType = Type.GetType(property.PropertyType);
if(propType.IsValueType)
{
propType = GetNullableType(propType);
}
var primitivePropertyConfiguration = myConfig.HasArtificialPrimitiveProperty(property.PropertyName,propType).HasFieldName(property.PropertyName);

Here I check if the Type of the field is a value type and if it is, then I create a nullable CLR type instead of the non-nullable type.

The helper method used is as below

public static Type GetNullableType(Type type)
{
if (type.IsValueType)
{
Type nullable = typeof(Nullable);
return nullable.MakeGenericType(new[] { type });
}
return type;
}

Hope this help !

Categories: ASP.NET

EXT.NET : Getting selected RadioGroup value through inputValue

January 11, 2018 Leave a comment

How to get selected value from RadioGroup in EXT.NET

Consider following sample code

On the server side I would like to be able to do something similar to this:

var value = typeRadioGroup.CheckedItems[0].InputValue;

to get the selected value directly and proceed with the code instead of calling e.g.

if (dailyRadio.Checked)
// do something
else if (weeklyRadioChecked)
// something else

Hope This help !

Categories: Ext.NEt, Tips & Tricks Tags: ,

Data Annotations – ForeignKey Attribute in EF 6 & EF Core

January 7, 2018 Leave a comment

The ForeignKey attribute is used to configure a foreign key in the relationship between two entities in EF 6 and EF Core. It overrides the default conventions. As per the default convention, EF makes a property as foreign key property when its name matches with the primary key property of a related entity.

ForeignKey Signature: [ForeignKey(name string)]

  • name: Name of the associated navigation property or the name of the associated foreign key(s).

Consider the following example of one-to-many relationship among entities.

public class Student
{
    public int StudentID { get; set; }
    public string StudentName { get; set; }
        
    //Foreign key for Standard
    public int StandardId { get; set; }
    public Standard Standard { get; set; }
}

public class Standard
{
    public int StandardId { get; set; }
    public string StandardName { get; set; }
    
    public ICollection<Student> Students { get; set; }
}

The above example depicts a one-to-many relationship between Student and Standard entities. To represent this relationship, the Student class includes a property StandardId with reference property Standard and Standard entity class includes collection navigation property Students. A property name StandardId in Student entity matches with the primary key property of Standard entity, so StandardIdin Student entity will automatically become a foreign key property and corresponding column in the db table will also be a foreign key column as shown below.

Entity Framework code-first example

The [ForeignKey] attribute overrides the default convention for a foreign key It allows us to specify the foreign key property in the dependent entity whose name does not match with the primary key property of the principal entity.

The [ForeignKey(name)] attribute can be applied in three ways:

  1. [ForeignKey(NavigationPropertyName)] on the foreign key scalar property in the dependent entity
  2. [ForeignKey(ForeignKeyPropertyName)] on the related reference navigation property in the dependent entity
  3. [ForeignKey(ForeignKeyPropertyName)] on the navigation property in the principal entity

[ForeignKey] on the foreign key property in the dependent entity:

The [ForeignKey] on the foreign key property in the dependent entity and the related navigation property name can be specified as a parameter as shown below.

public class Student
{
    public int StudentID { get; set; }
    public string StudentName { get; set; }
        
    [ForeignKey("Standard")]
    public int StandardRefId { get; set; }
    public Standard Standard { get; set; }
}

public class Standard
{
    public int StandardId { get; set; }
    public string StandardName { get; set; }
    
    public ICollection<Student> Students { get; set; }
}

In the above example, the [ForeignKey] attribute is applied on the StandardRefId and specified the name of the navigation property Standard. This will create the foreign key column named StandardRefId in the Students table, preventing the generation of a StandardId column in the database.

Entity Framework code-first example

[ForeignKey] on the navigation property in the dependent entity:

The [ForeignKey] attribute can be applied to the navigation property and the related foreign key property name can be specified as shown below.

public class Student
{
    public int StudentID { get; set; }
    public string StudentName { get; set; }
        
    public int StandardRefId { get; set; }
    
    [ForeignKey("StandardRefId")]
    public Standard Standard { get; set; }
}

public class Standard
{
    public int StandardId { get; set; }
    public string StandardName { get; set; }
    
    public ICollection<Student> Students { get; set; }
}

In the above example, the [ForeignKey] attribute is applied on the Standard navigation property and specified the name of the foreign key property StandardRefId. This will create the foreign key column named StandardRefId in the Students table, preventing the generation of a StandardId column in the database.

[ForeignKey] on the navigation property in the principal entity:

The [ForeignKey] attribute can be applied to the navigation property in the principal entity and the related foreign key property name can be specified in the dependent entity as shown below.

public class Student
{
    public int StudentID { get; set; }
    public string StudentName { get; set; }
        
    public int StandardRefId { get; set; }
    public Standard Standard { get; set; }
}

public class Standard
{
    public int StandardId { get; set; }
    public string StandardName { get; set; }
    
    [ForeignKey("StandardRefId")]
    public ICollection<Student> Students { get; set; }
}

In the above example, the [ForeignKey] attribute is applied on the Students navigation property in the principal entity Standard. This will create a foreign key column StandardRefId in the Students table in the database.

Hope this help !