Click here to Skip to main content
16,004,828 members
Home / Discussions / Visual Basic
   

Visual Basic

 
Questionvb6 phsical keyboard detect Pin
Member 1160234116-Apr-15 21:01
Member 1160234116-Apr-15 21:01 
AnswerRe: vb6 phsical keyboard detect Pin
Dave Kreskowiak17-Apr-15 2:28
mveDave Kreskowiak17-Apr-15 2:28 
GeneralRe: vb6 phsical keyboard detect Pin
Member 1160234117-Apr-15 16:17
Member 1160234117-Apr-15 16:17 
AnswerRe: vb6 phsical keyboard detect Pin
Sascha Lefèvre17-Apr-15 3:00
professionalSascha Lefèvre17-Apr-15 3:00 
GeneralRe: vb6 phsical keyboard detect Pin
Member 1160234117-Apr-15 16:25
Member 1160234117-Apr-15 16:25 
QuestionHow to get the item's data type in an bound Bindingsource that actually is empty? Pin
dilkonika16-Apr-15 19:45
dilkonika16-Apr-15 19:45 
QuestionGet the primary key property name and the Foreign key property name of an arbitrary entity Pin
dilkonika16-Apr-15 16:56
dilkonika16-Apr-15 16:56 
AnswerRe: Get the primary key property name and the Foreign key property name of an arbitrary entity Pin
dilkonika19-Apr-15 4:56
dilkonika19-Apr-15 4:56 
For the Primary key :
Public Function Get_PK(ctx As MyEntities, entity As Object) As String
    Dim objectContext = DirectCast(ctx, System.Data.Entity.Infrastructure.IObjectContextAdapter).ObjectContext
    Dim t As Type = entity.GetType.BaseType 
    Dim m As MethodInfo = objectContext.GetType().GetMethod("CreateObjectSet", New Type() {})
    Dim generic As MethodInfo = m.MakeGenericMethod(t)
    Dim st As Object = generic.Invoke(objectContext, Nothing)
    Dim entitySetPI As PropertyInfo = st.GetType().GetProperty("EntitySet")
    Dim entitySet As Metadata.Edm.EntitySet = DirectCast(entitySetPI.GetValue(st, Nothing), Metadata.Edm.EntitySet)
    Dim keyNames As IEnumerable(Of String) = entitySet.ElementType.KeyMembers.[Select](Function(k) k.Name)
    Return keyNames(0)
End Function

For the Foreign key :
Public Function Get_FK(ctx As MyEntities, entity As Object, parenttable As String) As String
    Dim objectCont = DirectCast(ctx, System.Data.Entity.Infrastructure.IObjectContextAdapter).ObjectContext
    Dim t As Type = entity.GetType.BaseType
    Dim m As MethodInfo = objcont.GetType().GetMethod("CreateObjectSet", New Type() {})
    Dim generic As MethodInfo = m.MakeGenericMethod(t)
    Dim st As Object = generic.Invoke(objcont, Nothing)
    Dim entitySetPI As PropertyInfo = st.GetType().GetProperty("EntitySet")
    Dim entitySet As Metadata.Edm.EntitySet = DirectCast(entitySetPI.GetValue(st, Nothing), Metadata.Edm.EntitySet)
    Dim elementtype = entitySet.ElementType
    Dim entitymember = elementtype.NavigationProperties.Where(Function(t1) t1.ToEndMember.Name = parenttable)
    Return entitymember.First.GetDependentProperties.First.Name
End Function

Please give me some reputation , because I found the answer Poke tongue | ;-P
Questionvb.net 2010 sum value in a collectionh Pin
dcof16-Apr-15 11:48
dcof16-Apr-15 11:48 
AnswerRe: vb.net 2010 sum value in a collectionh Pin
Sascha Lefèvre16-Apr-15 12:27
professionalSascha Lefèvre16-Apr-15 12:27 
GeneralRe: vb.net 2010 sum value in a collectionh Pin
dcof17-Apr-15 4:17
dcof17-Apr-15 4:17 
GeneralRe: vb.net 2010 sum value in a collectionh Pin
Sascha Lefèvre17-Apr-15 6:07
professionalSascha Lefèvre17-Apr-15 6:07 
QuestionCreate a list of Unknown type at compile time Pin
dilkonika16-Apr-15 10:58
dilkonika16-Apr-15 10:58 
AnswerRe: Create a list of Unknown type at compile time Pin
Sascha Lefèvre16-Apr-15 11:02
professionalSascha Lefèvre16-Apr-15 11:02 
GeneralRe: Create a list of Unknown type at compile time Pin
dilkonika16-Apr-15 11:53
dilkonika16-Apr-15 11:53 
GeneralRe: Create a list of Unknown type at compile time Pin
Sascha Lefèvre16-Apr-15 12:15
professionalSascha Lefèvre16-Apr-15 12:15 
GeneralRe: Create a list of Unknown type at compile time Pin
dilkonika16-Apr-15 13:05
dilkonika16-Apr-15 13:05 
GeneralRe: Create a list of Unknown type at compile time Pin
Sascha Lefèvre16-Apr-15 13:14
professionalSascha Lefèvre16-Apr-15 13:14 
GeneralRe: Create a list of Unknown type at compile time Pin
dilkonika16-Apr-15 13:51
dilkonika16-Apr-15 13:51 
GeneralRe: Create a list of Unknown type at compile time Pin
Sascha Lefèvre16-Apr-15 14:18
professionalSascha Lefèvre16-Apr-15 14:18 
GeneralRe: Create a list of Unknown type at compile time Pin
dilkonika16-Apr-15 14:23
dilkonika16-Apr-15 14:23 
GeneralRe: Create a list of Unknown type at compile time Pin
Sascha Lefèvre16-Apr-15 14:39
professionalSascha Lefèvre16-Apr-15 14:39 
GeneralRe: Create a list of Unknown type at compile time Pin
dilkonika16-Apr-15 16:03
dilkonika16-Apr-15 16:03 
GeneralRe: Create a list of Unknown type at compile time Pin
Sascha Lefèvre17-Apr-15 2:53
professionalSascha Lefèvre17-Apr-15 2:53 
QuestionExtended ASCII with UTF-8 in VB.NET Pin
r_m_radha15-Apr-15 2:28
r_m_radha15-Apr-15 2:28 

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.