Hi Atsushi.
I think you can commit (it wasn't probably worth asking :)).
Pascal.
On Fri, Oct 24, 2008 at 20:34, Atsushi Eno <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I have a small patch to implement {what the subject says}, which
> is somehow used in my ASP.NET DynamicData sample.
>
> I'm not sure if it is what DBLinq exactly wants, but here is
> what I tried against .NET (pass 0 to 2 arguments):
>
> ----
> using System;
> using System.Collections.Generic;
> using System.Data.Linq;
> public class Test {
> public static void Main (string [] args)
> {
> var er = new EntityRef<Foo> (Array.ConvertAll<string,Foo> (
> args, s => new Foo (s)));
> Console.WriteLine (er.HasLoadedOrAssignedValue);
> Console.WriteLine (er.Entity);
> }
> }
> public class Foo {
> public Foo (string s)
> {
> S = s;
> }
> public string S;
> public override string ToString ()
> {
> return "<" + S + ">";
> }
> }
> ----
>
> Atsushi Eno
>
> >
>
> Index: src/DbLinq/Data/Linq/EntityRef.cs
> ===================================================================
> --- src/DbLinq/Data/Linq/EntityRef.cs (revision 115081)
> +++ src/DbLinq/Data/Linq/EntityRef.cs (working copy)
> @@ -42,9 +42,11 @@
> {
> private TEntity entity;
> private bool hasLoadedOrAssignedValue;
> + private IEnumerable<TEntity> source;
>
> public EntityRef(TEntity entity)
> {
> + this.source = null;
> this.entity = entity;
> hasLoadedOrAssignedValue = true;
> }
> @@ -52,11 +54,14 @@
> [DbLinqToDo]
> public EntityRef(IEnumerable<TEntity> source)
> {
> - throw new NotImplementedException();
> + this.source = source;
> + hasLoadedOrAssignedValue = false;
> + entity = null;
> }
>
> public EntityRef(EntityRef<TEntity> entityRef)
> {
> + this.source = null;
> this.entity = entityRef.Entity;
> hasLoadedOrAssignedValue = true;
> }
> @@ -65,6 +70,14 @@
> {
> get
> {
> + if (source != null) {
> + foreach (var s in source) {
> + if (entity != null)
> + throw new InvalidOperationException ("Sequence
> contains more than one element");
> + entity = null;
> + }
> + source = null;
> + }
> return entity;
> }
> set
>
>
--
Pascal.
jabber/gtalk: [EMAIL PROTECTED]
msn: [EMAIL PROTECTED]
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"DbLinq" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/dblinq?hl=en
-~----------~----~----~----~------~----~------~--~---