Click here to Skip to main content
15,877,051 members
Home / Discussions / C#
   

C#

 
GeneralRe: How To Make This Generic Pin
Kevin Marois31-Oct-17 5:55
professionalKevin Marois31-Oct-17 5:55 
QuestionWPF assembly in C# Pin
Benjamin Bruno30-Oct-17 19:36
Benjamin Bruno30-Oct-17 19:36 
AnswerRe: WPF assembly in C# Pin
Mycroft Holmes30-Oct-17 20:30
professionalMycroft Holmes30-Oct-17 20:30 
AnswerRe: WPF assembly in C# Pin
Pete O'Hanlon30-Oct-17 20:31
mvePete O'Hanlon30-Oct-17 20:31 
AnswerRe: WPF assembly in C# Pin
OriginalGriff30-Oct-17 20:37
mveOriginalGriff30-Oct-17 20:37 
AnswerRe: WPF assembly in C# Pin
Gerry Schmitz31-Oct-17 12:17
mveGerry Schmitz31-Oct-17 12:17 
GeneralRe: WPF assembly in C# Pin
peterkmx2-Nov-17 6:29
professionalpeterkmx2-Nov-17 6:29 
QuestionEnum of C# Data Types - byte[] and char[] Pin
Kevin Marois30-Oct-17 12:30
professionalKevin Marois30-Oct-17 12:30 
I'm working on a type converter for .Net to Sql and .Net to OleDb.

First, I create a class called DataType:
public class DataType
{
    public DotNetTypes? DotNetType { get; private set; }
    public SqlDbType? SqlDbType { get; private set; }
    public OleDbType? OleDbType { get; private set; }

    public DataType(DotNetTypes? dotNetType, SqlDbType? sqlDbType, OleDbType? oleDbType)
    {
        DotNetType = dotNetType;
        SqlDbType = sqlDbType;
        OleDbType = oleDbType;
    }
}

Next I load it like this:
private static List<DataType> DataTypes;

static DataTypeConversion()
{
    Load();
}

private static void Load()
{
    DataTypes = new List<DataType>
    {
        new DataType(DotNetTypes.Short, SqlDbType.SmallInt, null),
        new DataType(DotNetTypes.Int32, SqlDbType.Int, null),
        new DataType(DotNetTypes.Int64, SqlDbType.BigInt, null),
        new DataType(DotNetTypes.Boolean, SqlDbType.Bit, null),
        new DataType(DotNetTypes.Double, SqlDbType.Float, null),
        new DataType(DotNetTypes.Float, SqlDbType.Real, null),
        new DataType(DotNetTypes.Guid, SqlDbType.UniqueIdentifier, null),
        new DataType(DotNetTypes.Byte, SqlDbType.TinyInt, null),
        new DataType(DotNetTypes.DataTable, SqlDbType.Structured, null),

        new DataType(DotNetTypes.DateTime, SqlDbType.DateTime, null),
        new DataType(DotNetTypes.DateTime, SqlDbType.SmallDateTime, null),
        new DataType(DotNetTypes.DateTime, SqlDbType.Date, null),
        new DataType(DotNetTypes.DateTime, SqlDbType.Time, null),
        new DataType(DotNetTypes.DateTime, SqlDbType.DateTime2, null),

        new DataType(DotNetTypes.DateTimeOffset, SqlDbType.DateTimeOffset, null),

        new DataType(DotNetTypes.Object, SqlDbType.Variant, null),
        new DataType(DotNetTypes.Object, SqlDbType.Udt, null),

        new DataType(DotNetTypes.Decimal, SqlDbType.Decimal, null),
        new DataType(DotNetTypes.Decimal, SqlDbType.Money, null),
        new DataType(DotNetTypes.Decimal, SqlDbType.SmallMoney, null),

        new DataType(DotNetTypes.Byte, SqlDbType.Binary, null),
        new DataType(DotNetTypes.Byte, SqlDbType.Image, null),
        new DataType(DotNetTypes.Byte, SqlDbType.VarBinary, null),
        new DataType(DotNetTypes.Byte, SqlDbType.Timestamp, null),

        new DataType(DotNetTypes.String, SqlDbType.NVarChar, null),
        new DataType(DotNetTypes.String, SqlDbType.VarChar, null),
        new DataType(DotNetTypes.String, SqlDbType.Char, null),
        new DataType(DotNetTypes.String, SqlDbType.NChar, null),
        new DataType(DotNetTypes.String, SqlDbType.NText, null),
        new DataType(DotNetTypes.String, SqlDbType.Text, null),
        new DataType(DotNetTypes.String, SqlDbType.Xml, null)
    };
}
To do this I created an enum called DotNetTypes:
public enum DotNetTypes
{
    @Unknown,
    @Short,
    @Boolean,
    @Byte,
    @Char,
    @DateTime,
    @DateTimeOffset,
    @Decimal,
    @Double,
    @Int32,
    @Int16,
    @Int64,
    @Float,
    @Object,
    @SByte,
    @Single,
    @String,
    @UInt16,
    @UInt32,
    @UInt64,
    @Guid,
    @DataTable
}

Notice that in the Load method I have
new DataType(DotNetTypes.Byte, SqlDbType.Binary, null),
new DataType(DotNetTypes.Byte, SqlDbType.Image, null),
new DataType(DotNetTypes.Byte, SqlDbType.VarBinary, null),
new DataType(DotNetTypes.Byte, SqlDbType.Timestamp, null),
The problem is that these should be byte arrays, not byte. So what is the syntax for this in my DotNetTypes enum?
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.

GeneralRe: Enum of C# Data Types - byte[] and char[] Pin
Sascha Lefèvre30-Oct-17 14:06
professionalSascha Lefèvre30-Oct-17 14:06 
GeneralRe: Enum of C# Data Types - byte[] and char[] Pin
Kevin Marois31-Oct-17 4:56
professionalKevin Marois31-Oct-17 4:56 
GeneralRe: Enum of C# Data Types - byte[] and char[] Pin
Sascha Lefèvre31-Oct-17 5:20
professionalSascha Lefèvre31-Oct-17 5:20 
QuestionConvert an obsolete old REST documentation Pin
Member 1096750730-Oct-17 0:54
Member 1096750730-Oct-17 0:54 
QuestionHow calculate Checksum for barcode code128 auto? Pin
Le@rner29-Oct-17 20:01
Le@rner29-Oct-17 20:01 
AnswerRe: How calculate Checksum for barcode code128 auto? Pin
Richard MacCutchan29-Oct-17 22:27
mveRichard MacCutchan29-Oct-17 22:27 
AnswerRe: How calculate Checksum for barcode code128 auto? Pin
Sascha Lefèvre29-Oct-17 22:27
professionalSascha Lefèvre29-Oct-17 22:27 
QuestionNo overload for method, error in c# file for Unity. Pin
Member 1349123628-Oct-17 14:33
Member 1349123628-Oct-17 14:33 
AnswerRe: No overload for method, error in c# file for Unity. Pin
Sascha Lefèvre28-Oct-17 14:47
professionalSascha Lefèvre28-Oct-17 14:47 
PraiseRe: No overload for method, error in c# file for Unity. Pin
Member 1349123628-Oct-17 15:25
Member 1349123628-Oct-17 15:25 
QuestionC# Problem extracting file from .zip created with DotNetZip Pin
manic_drummer28-Oct-17 11:58
manic_drummer28-Oct-17 11:58 
AnswerRe: C# Problem extracting file from .zip created with DotNetZip Pin
Sascha Lefèvre28-Oct-17 13:35
professionalSascha Lefèvre28-Oct-17 13:35 
AnswerRe: C# Problem extracting file from .zip created with DotNetZip Pin
Bernhard Hiller30-Oct-17 4:18
Bernhard Hiller30-Oct-17 4:18 
Questionc#Move music files in listbox up or down Pin
Member 1348924427-Oct-17 5:00
Member 1348924427-Oct-17 5:00 
AnswerRe: c#Move music files in listbox up or down Pin
Richard MacCutchan27-Oct-17 5:11
mveRichard MacCutchan27-Oct-17 5:11 
GeneralRe: c#Move music files in listbox up or down Pin
Member 1348924427-Oct-17 5:18
Member 1348924427-Oct-17 5:18 
GeneralRe: c#Move music files in listbox up or down Pin
Richard MacCutchan27-Oct-17 5:51
mveRichard MacCutchan27-Oct-17 5:51 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.