Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
K

Kris Penner

@Kris Penner
About
Posts
3
Topics
2
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Custom Properties in partial class of Entities Framework object not displayed in ASP.NET Dynamic Data
    K Kris Penner

    Hello, I am trying to display in a Dynamic Data app, a custom property added to the partial class of an ADO.NET Entity Framework entity class. For example, where Person is a entity in a ADO.NET Entity Framework model, I would add:

    public partial class Person
    {
    public string FullName { get { return FirstName + " " + LastName; } }
    }

    However, with Dynamic Data, it uses the internal System.Web.DynamicData.ModelProviders.EFTableProvider for generating its columns collection which only allows properties defined in the entity model to be displayed - as in only the database columns, not custom added ones. Does anyone know any work arounds to this, or is it possible and I am missing something obvious. Seems silly I can't do this. LINQ to SQL with Dynamic Data can do this easy as it uses reflection in its DLinqTableProvider to find all properties in the object, not just those with mappings to database fields. EFTableProvider's enumerator to create its columns for Dynamic Data: foreach (EdmMember member in entityType.get_Members()) // only entity DB mapped fields are returned in the Members property DLinqTableProvider's enumerator to create its columns for Dynamic Data: IEnumerator<PropertyInfo> enumerator = this.GetOrderedProperties(rowType.get_Type()).GetEnumerator() where GetOrderedProperties returns a list of properties based on reflection: PropertyInfo[] properties = type.GetProperties(BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly); Anyone have any thoughts on how to do this effectively? I need the many-to-many relationship management that Entity Framework provides - otherwise I would stick with LINQ to SQL. Thanks for any help! Cheers, kris

    ASP.NET database csharp tutorial asp-net linq

  • LINQ to SQL - String.IndexOf() does not work with parameters of length 1
    K Kris Penner

    Okay, that makes sense... and what stuffed me up more is that I was testing it in SQL with 'i' instead of N'i' (using ascii instead of unicode). Well, thanks very much for clearing that up :)

    LINQ csharp database sql-server visual-studio linq

  • LINQ to SQL - String.IndexOf() does not work with parameters of length 1
    K Kris Penner

    Hi, Can anyone explain why LINQ to SQL translates the String.IndexOf(string value) method into this SQL:

    CASE
    WHEN (DATALENGTH(@p0) / 2) = 0 THEN 0
    ELSE CHARINDEX(@p0, [t0].[Name]) - 1
    END

    The WHEN statment restricts parameters to be a minimum length of 2. This prevents me from passing in a string with a length of 1 to the String.IndexOf() method. Is this due to some sort of SQL limitation? Is there away around this? I am running .Net 3.5 with SP1, Visual Studio 2008 with SP1, and SQL Server 2005. Thanks for any help, kp

    LINQ csharp database sql-server visual-studio linq
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups